Skip to content

Commit

Permalink
Remove "unfiltered" version of ListFiles, and add a default argument …
Browse files Browse the repository at this point in the history
…value of a blank string.

Use `std::string::empty()` instead of string compare, and remove redundant check.
  • Loading branch information
Malkierian committed Dec 8, 2024
1 parent 3435b55 commit d6ad7cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/resource/archive/ArchiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ bool ArchiveManager::HasFile(uint64_t hash) {
std::shared_ptr<std::vector<std::string>> ArchiveManager::ListFiles(const std::string& filter) {
auto list = std::make_shared<std::vector<std::string>>();
for (const auto& [hash, path] : mHashes) {
if (filter != "" && glob_match(filter.c_str(), path.c_str()) || filter == "") {
if (filter.empty() || glob_match(filter.c_str(), path.c_str())) {
list->push_back(path);
}
}
return list;
}

std::shared_ptr<std::vector<std::string>> ArchiveManager::ListFiles() {
return ListFiles("");
}

std::vector<uint32_t> ArchiveManager::GetGameVersions() {
return mGameVersions;
}
Expand Down
3 changes: 1 addition & 2 deletions src/resource/archive/ArchiveManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class ArchiveManager {
std::shared_ptr<File> LoadFile(uint64_t hash, std::shared_ptr<ResourceInitData> initData = nullptr);
bool HasFile(const std::string& filePath);
bool HasFile(uint64_t hash);
std::shared_ptr<std::vector<std::string>> ListFiles(const std::string& filter);
std::shared_ptr<std::vector<std::string>> ListFiles();
std::shared_ptr<std::vector<std::string>> ListFiles(const std::string& filter = "");
std::vector<uint32_t> GetGameVersions();
const std::string* HashToString(uint64_t hash) const;
bool IsGameVersionValid(uint32_t gameVersion);
Expand Down

0 comments on commit d6ad7cb

Please sign in to comment.