2013-01-31 22:27:00 +01:00
|
|
|
/**
|
|
|
|
|
******************************************************************************
|
|
|
|
|
* Xenia : Xbox 360 Emulator Research Project *
|
|
|
|
|
******************************************************************************
|
|
|
|
|
* Copyright 2013 Ben Vanik. All rights reserved. *
|
|
|
|
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
|
|
|
|
******************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
2015-06-27 22:31:21 +02:00
|
|
|
#include "xenia/vfs/device.h"
|
2013-01-31 22:27:00 +01:00
|
|
|
|
2015-06-28 07:37:49 +02:00
|
|
|
#include "xenia/base/logging.h"
|
|
|
|
|
|
2014-08-17 06:36:01 +02:00
|
|
|
namespace xe {
|
2015-06-27 22:31:21 +02:00
|
|
|
namespace vfs {
|
2013-01-31 22:27:00 +01:00
|
|
|
|
2015-06-28 01:27:24 +02:00
|
|
|
Device::Device(const std::string& mount_path) : mount_path_(mount_path) {}
|
2013-01-31 22:27:00 +01:00
|
|
|
|
2014-08-16 11:30:23 +02:00
|
|
|
Device::~Device() = default;
|
2014-08-17 06:36:01 +02:00
|
|
|
|
2015-06-28 07:37:49 +02:00
|
|
|
void Device::Dump(StringBuffer* string_buffer) {
|
2015-09-06 18:30:54 +02:00
|
|
|
auto global_lock = global_critical_region_.Acquire();
|
2015-06-29 02:33:06 +02:00
|
|
|
root_entry_->Dump(string_buffer, 0);
|
|
|
|
|
}
|
2015-06-28 07:37:49 +02:00
|
|
|
|
2015-06-29 14:07:29 +02:00
|
|
|
Entry* Device::ResolvePath(std::string path) {
|
2015-06-28 07:37:49 +02:00
|
|
|
// The filesystem will have stripped our prefix off already, so the path will
|
|
|
|
|
// be in the form:
|
|
|
|
|
// some\PATH.foo
|
|
|
|
|
|
2015-06-29 14:07:29 +02:00
|
|
|
XELOGFS("Device::ResolvePath(%s)", path.c_str());
|
2015-06-28 07:37:49 +02:00
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-27 22:31:21 +02:00
|
|
|
} // namespace vfs
|
2014-08-17 06:36:01 +02:00
|
|
|
} // namespace xe
|