1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

LibCore: Add CDirIterator, and use it in everything rather than readdir

This commit is contained in:
Robin Burchell 2019-05-27 09:26:54 +02:00 committed by Andreas Kling
parent f352a5094d
commit 9d2b08e06e
9 changed files with 152 additions and 55 deletions

View file

@ -10,22 +10,22 @@
#include <AK/Vector.h>
#include <AK/FileSystemPath.h>
#include <LibCore/CArgsParser.h>
#include <LibCore/CDirIterator.h>
#include <LibGUI/GDesktop.h>
#include <LibGUI/GApplication.h>
static int handle_show_all()
{
DIR* dirp = opendir("/res/wallpapers");
if (!dirp) {
perror("opendir");
CDirIterator di("/res/wallpapers", CDirIterator::SkipDots);
if (di.has_error()) {
fprintf(stderr, "CDirIterator: %s\n", di.error_string());
return 1;
}
while (auto* de = readdir(dirp)) {
if (de->d_name[0] == '.')
continue;
printf("%s\n", de->d_name);
while (di.has_next()) {
String name = di.next_path();
printf("%s\n", name.characters());
}
closedir(dirp);
return 0;
}