+#endif
+
+#if PLATFORM_UNIX
+const char* Folders::getHomeDirectory()
+{
+ const char *homedir = getenv("HOME");
+ if (homedir != NULL)
+ return homedir;
+ struct passwd *pw = getpwuid(getuid());
+ if (pw != NULL)
+ return pw->pw_dir;
+ return NULL;
+}
+#endif
+
+bool Folders::makeDirectory(std::string path) {
+#ifdef _WIN32
+ int status = CreateDirectory(path.c_str(), NULL);
+ if (status != 0) {
+ return true;
+ } else if(GetLastError() == ERROR_ALREADY_EXISTS) {
+ return true;
+ } else {
+ return false;
+ }
+#else
+ errno = 0;
+ int status = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ if (status == 0) {
+ return true;
+ } else if(errno == EEXIST) {
+ return true;
+ } else {
+ return false;
+ }
+#endif
+}
+
+FILE* Folders::openMandatoryFile(std::string filename, const char* mode)
+{
+ FILE* tfile = fopen(filename.c_str(), mode);
+ if (tfile == NULL) {
+ throw FileNotFoundException(filename);
+ }
+ return tfile;
+}