From 734ee0f6352fdb6077c142d90f191c11c32f98d2 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Sun, 26 Jun 2022 21:57:43 -0400 Subject: Alias filesystem library to allow for xp usage MacOS 10.14 still uses experimental/filesystem which is what we're currently targetting. If I can get my hands on a 10.15+ we can test that out --- src/resources/Resources.cpp | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'src/resources/Resources.cpp') diff --git a/src/resources/Resources.cpp b/src/resources/Resources.cpp index 3ae93f4..ee43002 100644 --- a/src/resources/Resources.cpp +++ b/src/resources/Resources.cpp @@ -30,18 +30,18 @@ #include Resources::Resources() { - this->font = std::make_shared(); - this->defaultsLua = std::make_shared(); + this->font = std::make_shared(); + this->defaultsLua = std::make_shared(); } void Resources::loadFontFiles() { // We will search 1 level deep for (auto &base : this->fontSearchDirs()) { - if (std::filesystem::exists(base) && std::filesystem::is_directory(base)) { - for (auto &item : std::filesystem::directory_iterator(base)) { + if (fs::exists(base) && fs::is_directory(base)) { + for (auto &item : fs::directory_iterator(base)) { // only 1 deep if (item.exists() && item.is_directory()) { - for (auto &file : std::filesystem::directory_iterator(item)) { + for (auto &file : fs::directory_iterator(item)) { if (file.exists() && file.is_regular_file()) { auto ext = file.path().extension(); bool matched = @@ -84,10 +84,10 @@ void Resources::loadFontFiles() { void Resources::loadLevels() { for (auto &base : this->levelSearchDirs()) { - if (std::filesystem::exists(base) && std::filesystem::is_directory(base)) { - for (auto &dir : std::filesystem::directory_iterator(base)) { + if (fs::exists(base) && fs::is_directory(base)) { + for (auto &dir : fs::directory_iterator(base)) { if (dir.exists() && dir.is_directory()) { - if (std::filesystem::exists(dir / DNG_MAP)) { + if (fs::exists(dir / DNG_MAP)) { this->levels.push_back(dir.path()); } } @@ -99,42 +99,35 @@ void Resources::loadLevels() { void Resources::loadDefaultLuaFile() { for (auto &base : this->defaultsSearchDirs()) { auto f = base / DEFAULT_LUA; - if (std::filesystem::exists(f)) { + if (fs::exists(f)) { *this->defaultsLua = f; break; } } } -std::vector Resources::getFontFiles() { - return this->fonts; -} -std::vector Resources::getLevels() { - return this->levels; -} -shared_ptr Resources::getFontFile() { - return this->font; -} -shared_ptr Resources::updateFont(int idx) { +std::vector Resources::getFontFiles() { return this->fonts; } +std::vector Resources::getLevels() { return this->levels; } +shared_ptr Resources::getFontFile() { return this->font; } +shared_ptr Resources::updateFont(int idx) { auto f = this->fonts[idx]; *this->font = f; return getFontFile(); } -shared_ptr Resources::getDefaultsLuaFile() { +shared_ptr Resources::getDefaultsLuaFile() { return this->defaultsLua; } -shared_ptr Resources::getLevelMap(int idx) { +shared_ptr Resources::getLevelMap(int idx) { auto lvlBase = this->levels[idx]; - std::filesystem::path dngMap = lvlBase / DNG_MAP; + fs::path dngMap = lvlBase / DNG_MAP; // existence of the level dng.map is asserted in the initializer - assert(std::filesystem::exists(dngMap)); - return std::make_shared(dngMap); + assert(fs::exists(dngMap)); + return std::make_shared(dngMap); } -std::optional> -Resources::getLevelProcLua(int idx) { +std::optional> Resources::getLevelProcLua(int idx) { auto lvlBase = this->levels[idx]; auto procLua = lvlBase / PROC_LUA; if (exists(procLua)) { - return std::make_shared(procLua); + return std::make_shared(procLua); } else { return nullopt; } -- cgit v1.2.3-54-g00ecf