[ox/fs] Make some PassThroughFS functions noexcept

This commit is contained in:
Gary Talent 2022-07-12 00:51:35 -05:00
parent 82dc1895d5
commit ca9bf786b1
2 changed files with 12 additions and 6 deletions

View File

@ -20,10 +20,10 @@ PassThroughFS::PassThroughFS(const char *dirPath) {
m_path = dirPath; m_path = dirPath;
} }
PassThroughFS::~PassThroughFS() { PassThroughFS::~PassThroughFS() noexcept {
} }
String PassThroughFS::basePath() { String PassThroughFS::basePath() const noexcept {
return m_path.string().c_str(); return m_path.string().c_str();
} }
@ -43,8 +43,14 @@ Error PassThroughFS::mkdir(const char *path, bool recursive) noexcept {
} }
} else { } else {
std::error_code ec; std::error_code ec;
success = std::filesystem::create_directory(p, ec); const auto isDir = std::filesystem::is_directory(p, ec);
oxReturnError(OxError(ec.value(), "PassThroughFS: mkdir failed")); if (isDir) {
success = true;
} else {
std::error_code ec;
success = std::filesystem::create_directory(p, ec);
oxReturnError(OxError(ec.value(), "PassThroughFS: mkdir failed"));
}
} }
return OxError(success ? 0 : 1); return OxError(success ? 0 : 1);
} }

View File

@ -32,10 +32,10 @@ class PassThroughFS: public FileSystem {
public: public:
explicit PassThroughFS(const char *dirPath); explicit PassThroughFS(const char *dirPath);
~PassThroughFS() override; ~PassThroughFS() noexcept override;
[[nodiscard]] [[nodiscard]]
String basePath(); String basePath() const noexcept;
Error mkdir(const char *path, bool recursive = false) noexcept override; Error mkdir(const char *path, bool recursive = false) noexcept override;