Common: Fix dir listing extension filter.

Oops.  Also correct std::move() usage, which assumed it cleared the
source string.
This commit is contained in:
Unknown W. Brackets 2021-05-10 21:28:51 -07:00
parent b3ce171523
commit 36549a960f
3 changed files with 7 additions and 3 deletions

View File

@ -130,6 +130,7 @@ size_t GetFilesInDir(const char *directory, std::vector<FileInfo> * files, const
while (*filter) {
if (*filter == ':') {
filters.insert(std::move(tmp));
tmp.clear();
} else {
tmp.push_back(*filter);
}
@ -196,9 +197,11 @@ size_t GetFilesInDir(const char *directory, std::vector<FileInfo> * files, const
info.isWritable = false; // TODO - implement some kind of check
if (!info.isDirectory) {
std::string ext = GetFileExtension(info.fullName);
if (filter) {
if (filters.find(ext) == filters.end())
if (!ext.empty()) {
ext = ext.substr(1); // Remove the dot.
if (filter && filters.find(ext) == filters.end()) {
continue;
}
}
}

View File

@ -102,6 +102,7 @@ std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const
while (*filter) {
if (*filter == ':') {
filters.insert("." + tmp);
tmp.clear();
} else {
tmp.push_back(*filter);
}

View File

@ -75,7 +75,7 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::Fil
while (*filter) {
if (*filter == ':') {
filters.insert("." + tmp);
tmp = "";
tmp.clear();
} else {
tmp.push_back(*filter);
}