diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-17 21:14:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-17 21:14:26 +0200 |
commit | fa4cb80a1eee24dec947ed5a262a917518d6c799 (patch) | |
tree | f7e7d65c0c29f77d631c4ff70b6c85d09acc22c6 | |
parent | d087a9e3283528792634de84b55a607d9b9b5137 (diff) | |
parent | 1898a559a94d803ba3ead9127deb65c5a61aefaa (diff) |
Merge pull request #30657 from hadrien-psydk/optimize_dir_access_unix_get_next
Optimize DirAccessUnix::get_next() for some file systems
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 251bab5783..d5582d00ed 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -136,27 +136,31 @@ String DirAccessUnix::get_next() { return ""; } - //typedef struct stat Stat; - struct stat flags; - String fname = fix_unicode_name(entry->d_name); - String f = current_dir.plus_file(fname); + if (entry->d_type == DT_UNKNOWN) { + //typedef struct stat Stat; + struct stat flags; + + String f = current_dir.plus_file(fname); + + if (stat(f.utf8().get_data(), &flags) == 0) { - if (stat(f.utf8().get_data(), &flags) == 0) { + if (S_ISDIR(flags.st_mode)) { - if (S_ISDIR(flags.st_mode)) { + _cisdir = true; - _cisdir = true; + } else { + + _cisdir = false; + } } else { _cisdir = false; } - } else { - - _cisdir = false; + _cisdir = (entry->d_type == DT_DIR); } _cishidden = (fname != "." && fname != ".." && fname.begins_with(".")); |