mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Windows: Properly check for hidden files when enumerating files
This commit is contained in:
parent
71ab845564
commit
2479427992
@ -211,20 +211,19 @@ bool FileInfo::operator <(const FileInfo &other) const {
|
||||
size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const char *filter, int flags) {
|
||||
size_t foundEntries = 0;
|
||||
std::set<std::string> filters;
|
||||
std::string tmp;
|
||||
if (filter) {
|
||||
std::string tmp;
|
||||
while (*filter) {
|
||||
if (*filter == ':') {
|
||||
filters.insert(tmp);
|
||||
tmp = "";
|
||||
filters.insert(std::move(tmp));
|
||||
} else {
|
||||
tmp.push_back(*filter);
|
||||
}
|
||||
filter++;
|
||||
}
|
||||
if (!tmp.empty())
|
||||
filters.insert(std::move(tmp));
|
||||
}
|
||||
if (tmp.size())
|
||||
filters.insert(tmp);
|
||||
#ifdef _WIN32
|
||||
// Find the first file in the directory.
|
||||
WIN32_FIND_DATA ffd;
|
||||
@ -252,14 +251,20 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
|
||||
const std::string virtualName(result->d_name);
|
||||
#endif
|
||||
// check for "." and ".."
|
||||
if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
|
||||
((virtualName[0] == '.') && (virtualName[1] == '.') &&
|
||||
(virtualName[2] == '\0')))
|
||||
if (virtualName == "." || virtualName == "..")
|
||||
continue;
|
||||
|
||||
// Remove dotfiles (optional with flag.)
|
||||
if (!(flags & GETFILES_GETHIDDEN) && virtualName[0] == '.')
|
||||
continue;
|
||||
if (!(flags & GETFILES_GETHIDDEN))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)
|
||||
continue;
|
||||
#else
|
||||
if (virtualName[0] == '.')
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
|
||||
FileInfo info;
|
||||
info.name = virtualName;
|
||||
@ -283,7 +288,7 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
|
||||
}
|
||||
|
||||
if (files)
|
||||
files->push_back(info);
|
||||
files->push_back(std::move(info));
|
||||
foundEntries++;
|
||||
#ifdef _WIN32
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
|
Loading…
Reference in New Issue
Block a user