diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-04-11 18:42:06 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-04-11 18:43:25 +0100 |
| commit | 05d69f7f8e195f7b4eaec01060b4800b03291df3 (patch) | |
| tree | a05f9e6bc62e7c7a2cf293a34675b75612c2af3e /src | |
| parent | ad94c01d795226600883ef6568bfb08c7d3327af (diff) | |
Use stat when listing files so that link to directories are handled as directories
Diffstat (limited to 'src')
| -rw-r--r-- | src/file.cc | 6 |
1 files 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<String> 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] != '.') { |
