apio
a164dcc160
All checks were successful
continuous-integration/drone/push Build is passing
libluna but for stuff that interests only userspace, like an argument parser or files or stuff like that.
36 lines
661 B
C++
36 lines
661 B
C++
#include <os/ArgumentParser.h>
|
|
|
|
#include <dirent.h>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
StringView pathname;
|
|
|
|
ArgumentParser parser;
|
|
parser.add_positional_argument(pathname, "directory", false, "/");
|
|
parser.parse(argc, argv);
|
|
|
|
DIR* dp = opendir(pathname.chars());
|
|
if (!dp)
|
|
{
|
|
perror("opendir");
|
|
return 1;
|
|
}
|
|
|
|
int first_ent = 1;
|
|
do {
|
|
struct dirent* ent = readdir(dp);
|
|
if (!ent) break;
|
|
printf(first_ent ? "%s" : " %s", ent->d_name);
|
|
first_ent = 0;
|
|
} while (1);
|
|
|
|
putchar('\n');
|
|
|
|
closedir(dp);
|
|
return 0;
|
|
}
|