X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;ds=sidebyside;f=Source%2FUtils%2FFolders.cpp;h=3fa04025823b3502f4959ebc50e8a5fb83d6b57f;hb=d3f16728298e0639a3b2e916386f4e8cea4018ff;hp=21322c1596e192821765e8159811efa77f72a68a;hpb=cf610b0dfbf15ffafaefcae72a44957095fd7740;p=lugaru.git diff --git a/Source/Utils/Folders.cpp b/Source/Utils/Folders.cpp index 21322c1..3fa0402 100644 --- a/Source/Utils/Folders.cpp +++ b/Source/Utils/Folders.cpp @@ -117,11 +117,11 @@ const char* Folders::getHomeDirectory() bool Folders::makeDirectory(const std::string& path) { #ifdef _WIN32 int status = CreateDirectory(path.c_str(), NULL); - return status != 0 || GetLastError() == ERROR_ALREADY_EXISTS; + return ((status != 0) || (GetLastError() == ERROR_ALREADY_EXISTS)); #else errno = 0; int status = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - return status == 0 || errno == EEXIST; + return ((status == 0) || (errno == EEXIST)); #endif } @@ -133,3 +133,15 @@ FILE* Folders::openMandatoryFile(const std::string& filename, const char* mode) } return tfile; } + +bool Folders::file_exists(const std::string& filepath) +{ + FILE* file; + file = fopen(filepath.c_str(), "rb"); + if (file == NULL) { + return false; + } else { + fclose(file); + return true; + } +}