summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-09-05 11:59:28 +0000
committernakeee <nakeee@gmail.com>2008-09-05 11:59:28 +0000
commit6edc2343037d0e5e185763cd709f584e83e06d75 (patch)
tree64027e4bb0d610e14d86379097bf0a588064ea8b /Source/Core/Common/Src/FileUtil.cpp
parentcf36d4ba58ed12987107fe44e810f148dca48801 (diff)
added createdir and isdirectory for nix
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@442 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index f6c6b75710..6ab7e09531 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -4,6 +4,7 @@
#include <shellapi.h>
#else
#include <sys/stat.h>
+#include <errno.h>
#endif
bool File::Exists(const std::string &filename)
@@ -21,8 +22,9 @@ bool File::IsDirectory(const std::string &filename) {
#ifdef _WIN32
return (GetFileAttributes(filename.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
#else
- // TODO: Insert POSIX code here.
- return false;
+ struct stat file_info;
+ int result = stat(filename.c_str(), &file_info);
+ return S_ISDIR(file_info.st_mode);
#endif
}
@@ -79,7 +81,18 @@ bool File::CreateDir(const std::string &path)
PanicAlert("Error creating directory: %i", error);
return false;
#else
- // TODO: Insert POSIX code here.
- return true;
+ if (mkdir(path.c_str(), 0644) == 0)
+ return true;
+
+ int err = errno;
+
+ if (err == EEXIST) {
+ PanicAlert("%s already exists", path.c_str());
+ return true;
+ }
+
+ PanicAlert("Error creating directory: %s", strerror(err));
+ return false;
+
#endif
}