Refactoring vfs to remove a lot of duplicated code.

Progress on #294.
This commit is contained in:
Ben Vanik
2015-06-27 22:37:49 -07:00
parent 1ac19f1b08
commit 83872d8e8f
37 changed files with 877 additions and 1366 deletions

View File

@@ -9,6 +9,8 @@
#include "xenia/vfs/device.h"
#include "xenia/base/logging.h"
namespace xe {
namespace vfs {
@@ -16,5 +18,31 @@ Device::Device(const std::string& mount_path) : mount_path_(mount_path) {}
Device::~Device() = default;
void Device::Dump(StringBuffer* string_buffer) {
if (root_entry_) {
root_entry_->Dump(string_buffer, 0);
}
}
Entry* Device::ResolvePath(const char* path) {
// The filesystem will have stripped our prefix off already, so the path will
// be in the form:
// some\PATH.foo
XELOGFS("Device::ResolvePath(%s)", path);
// Walk the path, one separator at a time.
auto entry = root_entry_.get();
auto path_parts = xe::split_path(path);
for (auto& part : path_parts) {
entry = entry->GetChild(part);
if (!entry) {
// Not found.
return nullptr;
}
}
return entry;
}
} // namespace vfs
} // namespace xe