Cleanup & optimizations

This commit is contained in:
Anonymous275
2021-02-22 23:01:34 +02:00
committed by Anonymous275
parent 0580ad67fd
commit f52308c439
6 changed files with 34 additions and 26 deletions

View File

@@ -10,17 +10,23 @@ TResourceManager::TResourceManager() {
if (!fs::exists(Path))
fs::create_directories(Path);
for (const auto& entry : fs::directory_iterator(Path)) {
auto pos = entry.path().string().find(".zip");
if (pos != std::string::npos) {
if (entry.path().string().length() - pos == 4) {
mFileList += entry.path().string() + ";";
mFileSizes += std::to_string(uint64_t(fs::file_size(entry.path()))) + ";";
std::string File(entry.path().string());
if (auto pos = File.find(".zip"); pos != std::string::npos) {
if (File.length() - pos == 4) {
std::replace(File.begin(), File.end(),'\\','/');
mFileList += File + ';';
if(auto i = File.find_last_of('/'); i != std::string::npos){
++i;
File = File.substr(i,pos-i);
}
mTrimmedList += File + ';';
mFileSizes += std::to_string(uint64_t(fs::file_size(entry.path()))) + ';';
mMaxModSize += uint64_t(fs::file_size(entry.path()));
mModsLoaded++;
}
}
}
std::replace(mFileList.begin(), mFileList.end(), '\\', '/');
if (mModsLoaded)
info("Loaded " + std::to_string(mModsLoaded) + " Mods");
}