diff --git a/CMakeLists.txt b/CMakeLists.txt index 164f1292..c9de4223 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ endif() add_executable(${PROJECT_NAME} ${LIFISH_SRC}) set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO LINKER_LANGUAGE CXX diff --git a/src/core/utils.cpp b/src/core/utils.cpp index f0927087..4642dcc0 100644 --- a/src/core/utils.cpp +++ b/src/core/utils.cpp @@ -72,12 +72,7 @@ sf::View lif::keepRatio(const sf::Vector2f& size, const sf::Vector2u& designedsi return view; } -bool lif::createDirIfNotExisting(const std::string& path) { -#if defined(_WIN32) || defined(__MINGW32__) - bool ok = !!CreateDirectory(path.c_str(), NULL); - return ok || GetLastError() == ERROR_ALREADY_EXISTS; -#else - bool ok = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0; - return ok || errno == EEXIST; -#endif +bool lif::createDirIfNotExisting(const std::filesystem::path& path) { + bool ok = std::filesystem::create_directories(path); + return ok; } diff --git a/src/core/utils.hpp b/src/core/utils.hpp index 855c9350..84d1c2f7 100644 --- a/src/core/utils.hpp +++ b/src/core/utils.hpp @@ -8,6 +8,7 @@ #include #include #include +#include // Enable automatic sf::Time / json conversion: // https://github.com/nlohmann/json#basic-usage @@ -226,6 +227,6 @@ void testMusic(); sf::View keepRatio(const sf::Vector2f& size, const sf::Vector2u& designedsize); /** Note: this will NOT create a directory recursively */ -bool createDirIfNotExisting(const std::string& path); +bool createDirIfNotExisting(const std::filesystem::path& path); } // end namespace lif diff --git a/src/main.cpp b/src/main.cpp index 54b194ae..ccfddd24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -309,8 +309,10 @@ int main(int argc, char **argv) { if (ui.mustSaveGame()) { const auto saveName = ui.getSaveName() + ".lifish"; - lif::SaveManager::saveGame(saveName, game->getLM()); - std::cerr << "Saved game in " << saveName << "." << std::endl; + if (lif::SaveManager::saveGame(saveName, game->getLM())) + std::cerr << "Saved game in " << saveName << "." << std::endl; + else + std::cerr << "Failed to save game in " << saveName << "." << std::endl; } ///// LOGIC LOOP /////