From 6edc2343037d0e5e185763cd709f584e83e06d75 Mon Sep 17 00:00:00 2001 From: nakeee Date: Fri, 5 Sep 2008 11:59:28 +0000 Subject: [PATCH] added createdir and isdirectory for nix git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@442 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 21 +++++++++++++++++---- 1 file 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 #else #include +#include #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 }