summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index 6ab7e09531..1d79beef51 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -5,6 +5,7 @@
#else
#include <sys/stat.h>
#include <errno.h>
+#include <stdlib.h>
#endif
bool File::Exists(const std::string &filename)
@@ -24,7 +25,10 @@ bool File::IsDirectory(const std::string &filename) {
#else
struct stat file_info;
int result = stat(filename.c_str(), &file_info);
- return S_ISDIR(file_info.st_mode);
+ if (result == 0)
+ return S_ISDIR(file_info.st_mode);
+ else
+ return false;
#endif
}
@@ -96,3 +100,15 @@ bool File::CreateDir(const std::string &path)
#endif
}
+
+std::string GetUserDirectory() {
+#ifdef _WIN32
+ //TODO #endif
+#else
+ char *dir = getenv("HOME");
+ if (!dir)
+ return std::string("");
+
+ return dir;
+#endif
+}