about summary refs log tree commit diff
path: root/src/libutil/archive.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/archive.cc')
-rw-r--r--src/libutil/archive.cc21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc
index ed57df4c9f7b..f605e8b61954 100644
--- a/src/libutil/archive.cc
+++ b/src/libutil/archive.cc
@@ -51,23 +51,12 @@ static void dump(const string & path, DumpSink & sink);
 
 static void dumpEntries(const Path & path, DumpSink & sink)
 {
-    AutoCloseDir dir = opendir(path.c_str());
-    if (!dir) throw SysError("opening directory " + path);
+    Strings names = readDirectory(path);
+    vector<string> names2(names.begin(), names.end());
+    sort(names2.begin(), names2.end());
 
-    vector<string> names;
-
-    struct dirent * dirent;
-    while (errno = 0, dirent = readdir(dir)) {
-        string name = dirent->d_name;
-        if (name == "." || name == "..") continue;
-        names.push_back(name);
-    }
-    if (errno) throw SysError("reading directory " + path);
-
-    sort(names.begin(), names.end());
-
-    for (vector<string>::iterator it = names.begin();
-         it != names.end(); it++)
+    for (vector<string>::iterator it = names2.begin();
+         it != names2.end(); it++)
     {
         writeString("entry", sink);
         writeString("(", sink);