X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=blobdiff_plain;f=Source%2FUtils%2FFolders.hpp;h=2399506cb7076efd8773fef434ad91dd1389ddbd;hp=52be0f0d8b59d0b81042a6ef44308bfd3eb4e936;hb=7ed95b0f483ca64a550e391f8151d7ceb30acc18;hpb=ed3662c0852c4312a612b4fc35bd03aba8d13db7 diff --git a/Source/Utils/Folders.hpp b/Source/Utils/Folders.hpp index 52be0f0..2399506 100644 --- a/Source/Utils/Folders.hpp +++ b/Source/Utils/Folders.hpp @@ -30,9 +30,10 @@ along with Lugaru. If not, see . struct FileNotFoundException: public std::exception { std::string errorText; - FileNotFoundException (const std::string& filename) { - errorText = filename + " could not be found"; - } + + FileNotFoundException (const std::string& filename) + : errorText(filename + " could not be found") + {} const char * what () const throw () { return errorText.c_str(); @@ -44,24 +45,32 @@ class Folders static const std::string dataDir; public: - /* Returns path to the screenshot directory. Creates it if needed. */ + /** Returns path to the screenshot directory. Creates it if needed. */ static std::string getScreenshotDir(); - /* Returns full path for a game resource */ - static std::string getResourcePath(std::string filepath); - - /* Returns full path for user data */ + /** Returns full path for user data */ static std::string getUserDataPath(); - /* Returns full path for config file */ + /** Returns full path for config file */ static std::string getConfigFilePath(); - static FILE* openMandatoryFile(std::string filename, const char* mode); + static FILE* openMandatoryFile(const std::string& filename, const char* mode); + + static bool file_exists(const std::string& filepath); + + /* Returns full path for a game resource */ + static inline std::string getResourcePath(const std::string& filepath) + { return dataDir + '/' + filepath; } + + /** Returns full path for user progress save */ + static inline std::string getUserSavePath() + { return getUserDataPath() + "/users"; } + + static bool makeDirectory(const std::string& path); private: static const char* getHomeDirectory(); - static std::string getGenericDirectory(const char* ENVVAR, const std::string fallback); - static bool makeDirectory(std::string path); + static std::string getGenericDirectory(const char* ENVVAR, const std::string& fallback); }; #endif /* _FOLDERS_H_ */