/** * @brief create a directory * * Works like mkdir -p, ie. attempts to create parent directories too. * Operates on the current working directory. */ bool FileSystem::CreateDirectory(std::string dir) const { if (!CheckFile(dir)) return false; ForwardSlashes(dir); size_t prev_slash = 0, slash; while ((slash = dir.find('/', prev_slash + 1)) != std::string::npos) { if (!fs.mkdir(dir.substr(0, slash))) return false; prev_slash = slash; } return fs.mkdir(dir); }
/** * @brief create a directory * * Works like mkdir -p, ie. attempts to create parent directories too. * Operates on the current working directory. */ bool FileSystem::CreateDirectory(std::string dir) const { if (!CheckFile(dir)) return false; ForwardSlashes(dir); size_t prev_slash = 0, slash; while ((slash = dir.find('/', prev_slash + 1)) != std::string::npos) { std::string pathPart = dir.substr(0, slash); if (!FileSystemHandler::IsFSRoot(pathPart) && !fs.mkdir(pathPart)) { return false; } prev_slash = slash; } return fs.mkdir(dir); }
bool FileSystem::CreateDirectory(std::string dir) { if (!CheckFile(dir)) { return false; } ForwardSlashes(dir); size_t prev_slash = 0, slash; while ((slash = dir.find('/', prev_slash + 1)) != std::string::npos) { std::string pathPart = dir.substr(0, slash); if (!FileSystemAbstraction::IsFSRoot(pathPart) && !FileSystemAbstraction::MkDir(pathPart)) { return false; } prev_slash = slash; } return FileSystemAbstraction::MkDir(dir); }