diff options
author | Nils ANDRÉ-CHANG <nils@nilsand.re> | 2019-09-12 21:28:49 +0100 |
---|---|---|
committer | Nils ANDRÉ-CHANG <nils@nilsand.re> | 2019-09-26 20:36:12 +0100 |
commit | 0024dd7bb5a8a5194ed0283fc506edcd8b4a7737 (patch) | |
tree | 86316cccbf4fda58a275a7451e37fda83465bb20 /drivers/unix/dir_access_unix.cpp | |
parent | cafb888361eba08297dd88b18dc71f4d418525c0 (diff) | |
parent | 24e1039eb6fe32115e8d1a62a84965e9be19a2ed (diff) |
Merge branch 'master' into tab_key
Diffstat (limited to 'drivers/unix/dir_access_unix.cpp')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index d5582d00ed..6817137a94 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -126,37 +126,28 @@ String DirAccessUnix::get_next() { if (!dir_stream) return ""; - dirent *entry; - entry = readdir(dir_stream); + dirent *entry = readdir(dir_stream); if (entry == NULL) { - list_dir_end(); return ""; } String fname = fix_unicode_name(entry->d_name); - if (entry->d_type == DT_UNKNOWN) { - //typedef struct stat Stat; - struct stat flags; - + // Look at d_type to determine if the entry is a directory, unless + // its type is unknown (the file system does not support it) or if + // the type is a link, in that case we want to resolve the link to + // known if it points to a directory. stat() will resolve the link + // for us. + if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) { String f = current_dir.plus_file(fname); + struct stat flags; if (stat(f.utf8().get_data(), &flags) == 0) { - - if (S_ISDIR(flags.st_mode)) { - - _cisdir = true; - - } else { - - _cisdir = false; - } - + _cisdir = S_ISDIR(flags.st_mode); } else { - _cisdir = false; } } else { |