apio
4a3a92e9d4
All checks were successful
continuous-integration/drone/push Build is passing
Apparently that's where it's supposed to be.
26 lines
642 B
C++
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;
|
|
}
|
|
}
|