1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:35:06 +00:00
serenity/Userland/ls.cpp
Andreas Kling bca4b71bfa Lots of hacking to make a very simple "ls" utility.
I added a dead-simple malloc that only allows allocations < 4096 bytes.
It just forwards the request to mmap() every time.

I also added simplified versions of opendir() and readdir().
2018-10-24 12:50:07 +02:00

17 lines
311 B
C++

#include <LibC/stdio.h>
#include <LibC/unistd.h>
#include <LibC/dirent.h>
int main(int c, char** v)
{
DIR* dirp = opendir("/");
if (!dirp) {
printf("opendir failed :(\n");
return 1;
}
while (auto* de = readdir(dirp)) {
printf("%s\n", de->d_name);
}
return 0;
}