From 3749fb510bde475ecca768d8597776bcfcce6c08 Mon Sep 17 00:00:00 2001 From: nakeee Date: Fri, 5 Sep 2008 13:12:47 +0000 Subject: [PATCH] added getuserdirectory git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@444 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 18 +++++++++++++++++- Source/Core/Common/Src/FileUtil.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) 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 #include +#include #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 +} diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 530785f851..52097a1e58 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -11,6 +11,7 @@ public: static void Explore(const std::string &path); static bool IsDirectory(const std::string &filename); static bool CreateDir(const std::string &filename); + static std::string GetUserDirectory(); }; #endif