mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-02 11:02:28 +02:00
added createdir and isdirectory for nix
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@442 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
cf36d4ba58
commit
6edc234303
@ -4,6 +4,7 @@
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool File::Exists(const std::string &filename)
|
bool File::Exists(const std::string &filename)
|
||||||
@ -21,8 +22,9 @@ bool File::IsDirectory(const std::string &filename) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (GetFileAttributes(filename.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
return (GetFileAttributes(filename.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
#else
|
#else
|
||||||
// TODO: Insert POSIX code here.
|
struct stat file_info;
|
||||||
return false;
|
int result = stat(filename.c_str(), &file_info);
|
||||||
|
return S_ISDIR(file_info.st_mode);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +81,18 @@ bool File::CreateDir(const std::string &path)
|
|||||||
PanicAlert("Error creating directory: %i", error);
|
PanicAlert("Error creating directory: %i", error);
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
// TODO: Insert POSIX code here.
|
if (mkdir(path.c_str(), 0644) == 0)
|
||||||
return true;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user