diff --git a/src/common/fileHelper.cpp b/src/common/fileHelper.cpp index a95c4c2..dd07f64 100644 --- a/src/common/fileHelper.cpp +++ b/src/common/fileHelper.cpp @@ -1,6 +1,7 @@ #include "fileHelper.h" #include +#include std::string Recon::getPath(const std::string &aFullPath) { @@ -38,4 +39,15 @@ std::string Recon::fixPathSlash(const std::string& aPath) return aPath; } return aPath + '/'; +} + +bool Recon::exists(const std::string &aPath) +{ + return access(aPath.c_str(), F_OK) == 0; +} + +bool Recon::mkdir(const std::string &aPath) +{ + if(isDirectory(aPath)) return true; + return ::mkdir(aPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0; } \ No newline at end of file diff --git a/src/common/fileHelper.h b/src/common/fileHelper.h index 7311171..ff06d07 100644 --- a/src/common/fileHelper.h +++ b/src/common/fileHelper.h @@ -12,6 +12,8 @@ namespace Recon std::string getPath(const std::string &aFullPath); bool endsWithMat(const std::string &aStr); bool isDirectory(const std::string &aPath); + bool exists(const std::string &aPath); + bool mkdir(const std::string &aPath); std::string fixPathSlash(const std::string& aPath); }