1#ifndef MODULEBASE_FS_COMPAT_H
2#define MODULEBASE_FS_COMPAT_H
31 if (path.empty() || path[0] ==
'/')
35 std::vector<char> cwd(256);
39 char* result = _getcwd(cwd.data(),
static_cast<int>(cwd.size()));
41 char* result = getcwd(cwd.data(), cwd.size());
43 if (result !=
nullptr)
45 return std::string(result) +
"/" + path;
51 cwd.resize(cwd.size() * 2);
69 return _mkdir(path.c_str());
71 return mkdir(path.c_str(), 0755);
96 return ret == 0 || errno == EEXIST;
Definition clebsch_gordan_coeff.cpp:8
int make_directory(const std::string &path)
Create a single directory, portably.
Definition fs_compat.h:66
bool ensure_directory(const std::string &path)
Ensure a directory exists, creating it lazily if needed.
Definition fs_compat.h:89
std::string absolute_path_for_log(const std::string &path)
Return an absolute path for logging, or the original path if getcwd fails.
Definition fs_compat.h:29