in util/FileCreator.cpp [298:337]
bool FileCreator::createDirRecursively(const std::string dir, bool force) {
// Skip writes is turned on. We shouldn't be creating files
if (skipWrites_) {
return false;
}
if (!force && dirCreated(dir)) {
return true;
}
WDT_CHECK(dir.back() == '/');
int64_t lastIndex = dir.size() - 1;
while (lastIndex > 0 && dir[lastIndex - 1] != '/') {
lastIndex--;
}
if (lastIndex > 0) {
if (!createDirRecursively(dir.substr(0, lastIndex), force)) {
return false;
}
}
std::string fullDirPath = getFullPath(dir);
int code = mkdir(fullDirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (code != 0 && errno != EEXIST && errno != EISDIR) {
WPLOG(ERROR) << "failed to make directory " << fullDirPath;
return false;
} else if (code != 0) {
WLOG(INFO) << "dir already exists " << fullDirPath;
} else {
WLOG(INFO) << "made dir " << fullDirPath;
}
{
std::lock_guard<std::mutex> lock(mutex_);
createdDirs_.insert(dir);
}
return true;
}