using namespace std::string_literals;
using namespace common;
using common::tools::ReportError;
+using common::tools::GetErrorString;
void Mkdir(const std::string& path) {
ScopeLogger("%s", path.c_str());
DIR* d = ::opendir(path.c_str());
if (nullptr == d) {
throw std::system_error{errno, std::generic_category(),
- "Failed to open directory: "s + std::strerror(errno)};
+ "Failed to open directory: "s + GetErrorString(errno)};
}
std::unique_ptr<DIR, void (*)(DIR*)> dir_ptr(d, [](DIR* d) {
if (0 != errno) {
throw std::system_error{errno, std::generic_category(),
- "Failed to read directory: "s + std::strerror(errno)};
+ "Failed to read directory: "s + GetErrorString(errno)};
}
}
auto res = remove(fpath);
if (res) {
- LoggerD("Failed to remove %s: %s", fpath, std::strerror(errno));
+ LoggerD("Failed to remove %s: %s", fpath, GetErrorString(errno));
return errno;
}
return 0;
res = EIO;
}
throw std::system_error{res, std::generic_category(),
- "Failed to remove directory recursively: "s + std::strerror(res)};
+ "Failed to remove directory recursively: "s + GetErrorString(res)};
}
}
return false;
} else {
throw std::system_error{errno, std::generic_category(),
- "Unable to check file existence: "s + std::strerror(errno)};
+ "Unable to check file existence: "s + GetErrorString(errno)};
}
}
return true;
ScopeLogger();
if (::rename(path.c_str(), new_path.c_str())) {
throw std::system_error{errno, std::generic_category(),
- "Unable to rename file or directory: "s + std::strerror(errno)};
+ "Unable to rename file or directory: "s + GetErrorString(errno)};
}
}
} else if (EXDEV != errno) {
// The directories are in the same mount point, but the operation has just failed.
throw std::system_error{EIO, std::generic_category(),
- "Unable to move directory: "s + std::strerror(errno)};
+ "Unable to move directory: "s + GetErrorString(errno)};
}
}