mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
chmod+mkdir: Use convert_to_uint_from_octal
This commit is contained in:
parent
9e97823ff8
commit
26bb3e1acf
2 changed files with 16 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -32,7 +33,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
mode_t mode = default_mode;
|
||||
|
||||
if (!mode_string.is_empty()) {
|
||||
if (sscanf(mode_string.characters(), "%ho", &mode) != 1) {
|
||||
mode = AK::StringUtils::convert_to_uint_from_octal<u16>(mode_string).value_or(01000);
|
||||
if (mode > 0777) {
|
||||
warnln("mkdir: invalid mode: {}", mode_string);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue