Luna/utils/chmod.cpp
apio 140910763e
All checks were successful
Build and test / build (push) Successful in 1m56s
all: Reorder directory structure
Why are command-line utilities stored in "apps"?
And why are apps like "editor" or "terminal" top-level directories?
Command-line utilities now go in "utils".
GUI stuff now goes in "gui".
This includes: libui -> gui/libui, wind -> gui/wind, GUI apps -> gui/apps, editor&terminal -> gui/apps...
System services go in "system".
2024-07-21 13:24:46 +02:00

26 lines
642 B
C++

#include <os/ArgumentParser.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main(int argc, char** argv)
{
StringView mode_string;
StringView path;
os::ArgumentParser parser;
parser.add_description("Change the permissions of a file."_sv);
parser.add_system_program_info("chmod"_sv);
parser.add_positional_argument(mode_string, "mode"_sv, true);
parser.add_positional_argument(path, "path"_sv, true);
parser.parse(argc, argv);
mode_t mode = (mode_t)strtoul(mode_string.chars(), NULL, 8);
if (chmod(path.chars(), mode) < 0)
{
perror("chmod");
return 1;
}
}