aboutsummaryrefslogtreecommitdiff
path: root/gitstatus/src/dir.cc
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2020-11-24 14:32:19 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2020-11-24 14:32:19 +0300
commit21df7db2b2d51526abad93e9415ce91823c808a0 (patch)
treec51ba532154639a6945272d640b60bd24d57367c /gitstatus/src/dir.cc
parent31ede3c1d348783239dbce37ae4123ae439d99a8 (diff)
parent39cf063480f6a378dadc802c174e96112c38c0c0 (diff)
Merge commit '39cf063480f6a378dadc802c174e96112c38c0c0'
Diffstat (limited to 'gitstatus/src/dir.cc')
-rw-r--r--gitstatus/src/dir.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/gitstatus/src/dir.cc b/gitstatus/src/dir.cc
index 1817e1d3..e7ce7141 100644
--- a/gitstatus/src/dir.cc
+++ b/gitstatus/src/dir.cc
@@ -211,14 +211,15 @@ char* DirenvConvert(Arena& arena, struct dirent& ent, bool do_convert) {
bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode,
bool case_sensitive) {
- VERIFY((dir_fd = dup(dir_fd)) >= 0);
+ entries.clear();
+ dir_fd = dup(dir_fd);
+ if (dir_fd < 0) return false;
DIR* dir = fdopendir(dir_fd);
if (!dir) {
CHECK(!close(dir_fd)) << Errno();
- return -1;
+ return false;
}
ON_SCOPE_EXIT(&) { CHECK(!closedir(dir)) << Errno(); };
- entries.clear();
while (struct dirent* ent = (errno = 0, readdir(dir))) {
if (Dots(ent->d_name)) continue;
entries.push_back(DirenvConvert(arena, *ent, precompose_unicode));