+#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(const std::string& path)
+{
+#ifdef _WIN32
+ int status = CreateDirectory(path.c_str(), NULL);
+ return ((status != 0) || (GetLastError() == ERROR_ALREADY_EXISTS));
+#else
+ errno = 0;
+ int status = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ return ((status == 0) || (errno == EEXIST));
+#endif
+}
+
+FILE* Folders::openMandatoryFile(const std::string& filename, const char* mode)
+{
+ FILE* tfile = fopen(filename.c_str(), mode);
+ if (tfile == NULL) {
+ throw FileNotFoundException(filename);
+ }
+ return tfile;
+}
+
+bool Folders::file_exists(const std::string& filepath)
+{
+ FILE* file;
+ file = fopen(filepath.c_str(), "rb");
+ if (file == NULL) {
+ return false;
+ } else {
+ fclose(file);
+ return true;
+ }
+}