fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user