X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FUtils%2FFolders.h;h=495f149bb080c5a2c8bcdd0cd15c703254f51a49;hb=e8886f08acfcbec9dbe361df12cff7ef96005a0e;hp=1dd46fbf2c1440a093ea1bf034fd93162646c1e6;hpb=8d45019f2b1ac74108ae4589333680158fee32d5;p=lugaru.git diff --git a/Source/Utils/Folders.h b/Source/Utils/Folders.h index 1dd46fb..495f149 100644 --- a/Source/Utils/Folders.h +++ b/Source/Utils/Folders.h @@ -23,10 +23,22 @@ along with Lugaru. If not, see . #include -#ifndef DATADIR -#define DATADIR "Data" +#ifndef DATA_DIR +#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,8 +56,12 @@ 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); + static bool makeDirectory(std::string path); }; #endif /* _FOLDERS_H_ */