]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Utils/Folders.h
Trying to handle a bit better missing files and avoid segfaults
[lugaru.git] / Source / Utils / Folders.h
index d511ac221c5d7d3261b33940a41f0ae7c1154809..495f149bb080c5a2c8bcdd0cd15c703254f51a49 100644 (file)
@@ -27,6 +27,18 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #define DATA_DIR "Data"
 #endif
 
+struct FileNotFoundException: public std::exception
+{
+    std::string errorText;
+    FileNotFoundException (const std::string& filename) {
+        errorText = filename + " could not be found";
+    }
+
+    const char * what () const throw () {
+        return errorText.c_str();
+    }
+};
+
 class Folders
 {
     static const std::string dataDir;
@@ -44,6 +56,8 @@ public:
     /* Returns full path for config file */
     static std::string getConfigFilePath();
 
+    static FILE* openMandatoryFile(std::string filename, const char* mode);
+
 private:
     static const char* getHomeDirectory();
     static std::string getGenericDirectory(const char* ENVVAR, const std::string fallback);