diff options
author | madmaxoft <github@xoft.cz> | 2013-10-09 09:57:48 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-10-09 09:57:48 +0200 |
commit | 55999ee1187579179a70328808a4c856339ca97f (patch) | |
tree | 6335123ef5b8ff43b2e38e76282c45c61270b235 /source/OSSupport/File.cpp | |
parent | Added static cFile functions to Lua API. (diff) | |
download | cuberite-55999ee1187579179a70328808a4c856339ca97f.tar cuberite-55999ee1187579179a70328808a4c856339ca97f.tar.gz cuberite-55999ee1187579179a70328808a4c856339ca97f.tar.bz2 cuberite-55999ee1187579179a70328808a4c856339ca97f.tar.lz cuberite-55999ee1187579179a70328808a4c856339ca97f.tar.xz cuberite-55999ee1187579179a70328808a4c856339ca97f.tar.zst cuberite-55999ee1187579179a70328808a4c856339ca97f.zip |
Diffstat (limited to '')
-rw-r--r-- | source/OSSupport/File.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source/OSSupport/File.cpp b/source/OSSupport/File.cpp index 16ec00e16..a3733933e 100644 --- a/source/OSSupport/File.cpp +++ b/source/OSSupport/File.cpp @@ -310,11 +310,11 @@ bool cFile::Copy(const AString & a_SrcFileName, const AString & a_DstFileName) bool cFile::IsFolder(const AString & a_Path) { #ifdef _WIN32 - DWORD FileAttrib = GetFileAttributes(a_Path.c_str()); - return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0)); + DWORD FileAttrib = GetFileAttributes(a_Path.c_str()); + return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0)); #else - struct stat st; - return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode)); + struct stat st; + return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode)); #endif } @@ -325,11 +325,11 @@ bool cFile::IsFolder(const AString & a_Path) bool cFile::IsFile(const AString & a_Path) { #ifdef _WIN32 - DWORD FileAttrib = GetFileAttributes(a_Path.c_str()); - return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0)); + DWORD FileAttrib = GetFileAttributes(a_Path.c_str()); + return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0)); #else - struct stat st; - return ((stat(a_Path.c_str(), &st) == 0) && S_ISREG(st.st_mode)); + struct stat st; + return ((stat(a_Path.c_str(), &st) == 0) && S_ISREG(st.st_mode)); #endif } @@ -351,6 +351,19 @@ int cFile::GetSize(const AString & a_FileName) +bool cFile::CreateFolder(const AString & a_FolderPath) +{ + #ifdef _WIN32 + return (CreateDirectory(a_FolderPath.c_str(), NULL) != 0); + #else + return (mkdir(a_FolderPath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0); + #endif +} + + + + + int cFile::Printf(const char * a_Fmt, ...) { AString buf; |