summaryrefslogtreecommitdiff
path: root/src/resources/Resources.cpp
diff options
context:
space:
mode:
authorSteph Enders <smenders@gmail.com>2022-06-26 21:57:43 -0400
committerSteph Enders <smenders@gmail.com>2022-06-26 21:57:43 -0400
commit734ee0f6352fdb6077c142d90f191c11c32f98d2 (patch)
tree4d4d40b7c9fcd4b900f45dfcdaf9d7c99e0d3ca8 /src/resources/Resources.cpp
parent49f22d6f41d46635502d9e2e492ee36a1197a4de (diff)
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
Diffstat (limited to 'src/resources/Resources.cpp')
-rw-r--r--src/resources/Resources.cpp47
1 files changed, 20 insertions, 27 deletions
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 <iostream>
Resources::Resources() {
- this->font = std::make_shared<std::filesystem::path>();
- this->defaultsLua = std::make_shared<std::filesystem::path>();
+ this->font = std::make_shared<fs::path>();
+ this->defaultsLua = std::make_shared<fs::path>();
}
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<std::filesystem::path> Resources::getFontFiles() {
- return this->fonts;
-}
-std::vector<std::filesystem::path> Resources::getLevels() {
- return this->levels;
-}
-shared_ptr<std::filesystem::path> Resources::getFontFile() {
- return this->font;
-}
-shared_ptr<std::filesystem::path> Resources::updateFont(int idx) {
+std::vector<fs::path> Resources::getFontFiles() { return this->fonts; }
+std::vector<fs::path> Resources::getLevels() { return this->levels; }
+shared_ptr<fs::path> Resources::getFontFile() { return this->font; }
+shared_ptr<fs::path> Resources::updateFont(int idx) {
auto f = this->fonts[idx];
*this->font = f;
return getFontFile();
}
-shared_ptr<std::filesystem::path> Resources::getDefaultsLuaFile() {
+shared_ptr<fs::path> Resources::getDefaultsLuaFile() {
return this->defaultsLua;
}
-shared_ptr<std::filesystem::path> Resources::getLevelMap(int idx) {
+shared_ptr<fs::path> 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<std::filesystem::path>(dngMap);
+ assert(fs::exists(dngMap));
+ return std::make_shared<fs::path>(dngMap);
}
-std::optional<shared_ptr<std::filesystem::path>>
-Resources::getLevelProcLua(int idx) {
+std::optional<shared_ptr<fs::path>> Resources::getLevelProcLua(int idx) {
auto lvlBase = this->levels[idx];
auto procLua = lvlBase / PROC_LUA;
if (exists(procLua)) {
- return std::make_shared<std::filesystem::path>(procLua);
+ return std::make_shared<fs::path>(procLua);
} else {
return nullopt;
}