]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Utils/Folders.hpp
clang-format: Apply to all headers
[lugaru.git] / Source / Utils / Folders.hpp
index 52be0f0d8b59d0b81042a6ef44308bfd3eb4e936..c2c85877c2017b74750eb2aa5d37282f25e65d07 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Copyright (C) 2003, 2010 - Wolfire Games
-Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
 
 This file is part of Lugaru.
 
@@ -27,14 +27,17 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #define DATA_DIR "Data"
 #endif
 
-struct FileNotFoundException: public std::exception
+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 () {
+    const char* what() const throw()
+    {
         return errorText.c_str();
     }
 };
@@ -44,24 +47,36 @@ 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_ */