completely remove EnginePaths::resolve

This commit is contained in:
MihailRis
2025-02-04 12:35:19 +03:00
parent b955ae59c1
commit a653b063e6
12 changed files with 67 additions and 106 deletions
+19 -1
View File
@@ -10,6 +10,18 @@ namespace fs = std::filesystem;
static debug::Logger logger("io-stdfs");
StdfsDevice::StdfsDevice(fs::path root, bool createDirectory)
: root(std::move(root)) {
if (createDirectory && !fs::is_directory(this->root)) {
std::error_code ec;
fs::create_directories(this->root, ec);
if (ec) {
logger.error() << "error creating root directory " << this->root
<< ": " << ec.message();
}
}
}
fs::path StdfsDevice::resolve(std::string_view path) {
return root / fs::u8path(path);
}
@@ -54,7 +66,13 @@ bool StdfsDevice::isfile(std::string_view path) {
void StdfsDevice::mkdirs(std::string_view path) {
auto resolved = resolve(path);
fs::create_directories(resolved);
std::error_code ec;
fs::create_directories(resolved, ec);
if (ec) {
logger.error() << "error creating directory " << resolved << ": "
<< ec.message();
}
}
bool StdfsDevice::remove(std::string_view path) {
+1 -1
View File
@@ -3,7 +3,7 @@
namespace io {
class StdfsDevice : public Device {
public:
StdfsDevice(std::filesystem::path root) : root(std::move(root)) {}
StdfsDevice(std::filesystem::path root, bool createDirectory = true);
std::filesystem::path resolve(std::string_view path) override;
void write(std::string_view path, const void* data, size_t size) override;