2023-04-08 12:47:58 +00:00
|
|
|
#include <os/ArgumentParser.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
StringView mode_string;
|
|
|
|
StringView path;
|
|
|
|
|
|
|
|
os::ArgumentParser parser;
|
2023-04-19 17:16:45 +00:00
|
|
|
parser.add_description("Change the permissions of a file."_sv);
|
2023-04-08 12:47:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|