summaryrefslogtreecommitdiff
path: root/Userland/pape.cpp
diff options
context:
space:
mode:
authorRobin Burchell <robin+git@viroteck.net>2019-05-27 09:26:54 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-27 15:27:23 +0200
commit9d2b08e06eb3139fcdebef283d0635365fddd4b5 (patch)
tree02084b0ffcc3c58f7d4d31d57fbce46f60d0d5b1 /Userland/pape.cpp
parentf352a5094d66052d855a23d9c01e5006da70cc1a (diff)
downloadserenity-9d2b08e06eb3139fcdebef283d0635365fddd4b5.zip
LibCore: Add CDirIterator, and use it in everything rather than readdir
Diffstat (limited to 'Userland/pape.cpp')
-rw-r--r--Userland/pape.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Userland/pape.cpp b/Userland/pape.cpp
index 910673d051..138b98642d 100644
--- a/Userland/pape.cpp
+++ b/Userland/pape.cpp
@@ -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;
}