This commit is contained in:
MihailRis
2025-11-16 18:35:04 +03:00
parent 2a8fa4f2fa
commit 536035441a
5 changed files with 26 additions and 3 deletions
+9
View File
@@ -59,10 +59,16 @@ io::file_time_type io::MemoryDevice::lastWriteTime(std::string_view path) {
}
bool io::MemoryDevice::exists(std::string_view path) {
if (path.empty()) {
return true;
}
return nodes.find(std::string(path)) != nodes.end();
}
bool io::MemoryDevice::isdir(std::string_view path) {
if (path.empty()) {
return true;
}
const auto& found = nodes.find(std::string(path));
if (found == nodes.end()) {
return false;
@@ -201,6 +207,9 @@ io::MemoryDevice::Node* io::MemoryDevice::createFile(
}
io::MemoryDevice::Dir* io::MemoryDevice::getDir(std::string_view path) {
if (path.empty()) {
return &rootDir;
}
const auto& found = nodes.find(std::string(path));
if (found == nodes.end()) {
return nullptr;
+1
View File
@@ -62,6 +62,7 @@ namespace io {
std::unique_ptr<PathsGenerator> list(std::string_view path) override;
private:
std::unordered_map<std::string, Node> nodes;
Dir rootDir {};
Node* createFile(std::string path, util::Buffer<char>&& content);
Dir* createDir(std::string path);