Add exists and mkdir to fileHelper
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include "fileHelper.h"
|
#include "fileHelper.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
std::string Recon::getPath(const std::string &aFullPath)
|
std::string Recon::getPath(const std::string &aFullPath)
|
||||||
{
|
{
|
||||||
@@ -38,4 +39,15 @@ std::string Recon::fixPathSlash(const std::string& aPath)
|
|||||||
return aPath;
|
return 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;
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,8 @@ namespace Recon
|
|||||||
std::string getPath(const std::string &aFullPath);
|
std::string getPath(const std::string &aFullPath);
|
||||||
bool endsWithMat(const std::string &aStr);
|
bool endsWithMat(const std::string &aStr);
|
||||||
bool isDirectory(const std::string &aPath);
|
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);
|
std::string fixPathSlash(const std::string& aPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user