From a0bae1855ff82cd56f79a80dec6e4f87f5a6582d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 10 Jul 2021 11:47:03 +0200 Subject: [PATCH] Path browser: Move special handling of Windows root directory to GetFilesInDir. --- Common/File/DirListing.cpp | 20 ++++++++++++++++++++ Common/File/PathBrowser.cpp | 25 +++---------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index 4988f7784e..04aef9e0f6 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -167,6 +167,26 @@ size_t GetFilesInDir(const Path &directory, std::vector * files, const return true; } +#if PPSSPP_PLATFORM(WINDOWS) + if (directory.IsRoot()) { + // Special path that means root of file system. + std::vector drives = File::GetWindowsDrives(); + for (auto drive = drives.begin(); drive != drives.end(); ++drive) { + if (*drive == "A:/" || *drive == "B:/") + continue; + File::FileInfo fake; + fake.fullName = Path(*drive); + fake.name = *drive; + fake.isDirectory = true; + fake.exists = true; + fake.size = 0; + fake.isWritable = false; + files->push_back(fake); + } + return files->size(); + } +#endif + size_t foundEntries = 0; std::set filters; if (filter) { diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 02043abdd1..26cfd64ef5 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -214,32 +214,13 @@ bool PathBrowser::GetListing(std::vector &fileInfo, const char * guard.lock(); } -#if PPSSPP_PLATFORM(WINDOWS) - if (path_.IsRoot()) { - // Special path that means root of file system. - std::vector drives = File::GetWindowsDrives(); - for (auto drive = drives.begin(); drive != drives.end(); ++drive) { - if (*drive == "A:/" || *drive == "B:/") - continue; - File::FileInfo fake; - fake.fullName = Path(*drive); - fake.name = *drive; - fake.isDirectory = true; - fake.exists = true; - fake.size = 0; - fake.isWritable = false; - fileInfo.push_back(fake); - } - } -#endif - if (path_.Type() == PathType::HTTP) { fileInfo = ApplyFilter(pendingFiles_, filter); return true; - } else { - File::GetFilesInDir(path_, &fileInfo, filter); - return true; } + + File::GetFilesInDir(path_, &fileInfo, filter); + return true; } bool PathBrowser::CanNavigateUp() {