From 05d69f7f8e195f7b4eaec01060b4800b03291df3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 11 Apr 2014 18:42:06 +0100 Subject: [PATCH] Use stat when listing files so that link to directories are handled as directories --- src/file.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/file.cc b/src/file.cc index 68c24bdd..c295217f 100644 --- a/src/file.cc +++ b/src/file.cc @@ -293,9 +293,11 @@ std::vector list_files(const String& prefix, const bool match_prefix = prefix_match(filename, prefix); const bool match_subseq = subsequence_match(filename, prefix); - if (match_prefix or match_subseq) + struct stat st; + if ((match_prefix or match_subseq) and + stat((dirname + filename).c_str(), &st) == 0) { - if (entry->d_type == DT_DIR) + if (S_ISDIR(st.st_mode)) filename += '/'; if (prefix.length() != 0 or filename[0] != '.') {