Use stat when listing files so that link to directories are handled as directories

This commit is contained in:
Maxime Coste 2014-04-11 18:42:06 +01:00
parent ad94c01d79
commit 05d69f7f8e

View File

@ -293,9 +293,11 @@ std::vector<String> list_files(const String& prefix,
const bool match_prefix = prefix_match(filename, prefix); const bool match_prefix = prefix_match(filename, prefix);
const bool match_subseq = subsequence_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 += '/'; filename += '/';
if (prefix.length() != 0 or filename[0] != '.') if (prefix.length() != 0 or filename[0] != '.')
{ {