1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-08-02 12:47:07 +01:00

Hadrons: automatic directory creation fix

This commit is contained in:
2018-04-23 18:45:39 +01:00
parent 2fa2b0e0b1
commit 6764362237
3 changed files with 24 additions and 6 deletions

View File

@@ -96,7 +96,7 @@ const std::string Hadrons::resultFileExt = "xml";
// recursive mkdir /////////////////////////////////////////////////////////////
int Hadrons::mkdir(const std::string dirName)
{
if (access(dirName.c_str(), R_OK|W_OK|X_OK))
if (!dirName.empty() and access(dirName.c_str(), R_OK|W_OK|X_OK))
{
mode_t mode755;
char tmp[MAX_PATH_LENGTH];
@@ -143,3 +143,18 @@ std::string Hadrons::basename(const std::string &s)
return s;
}
}
std::string Hadrons::dirname(const std::string &s)
{
constexpr char sep = '/';
size_t i = s.rfind(sep, s.length());
if (i != std::string::npos)
{
return s.substr(0, i);
}
else
{
return "";
}
}