Renaming xe::fs to xe::filesystem and xe::kernel::fs to xe::vfs.

Progress on #294.
This commit is contained in:
Ben Vanik
2015-06-27 13:31:21 -07:00
parent bc75b0ab87
commit 0716cf84c0
45 changed files with 374 additions and 428 deletions

View File

@@ -0,0 +1,70 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2014 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/vfs/devices/stfs_container_device.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/vfs/stfs.h"
#include "xenia/vfs/devices/stfs_container_entry.h"
#include "xenia/kernel/objects/xfile.h"
namespace xe {
namespace vfs {
STFSContainerDevice::STFSContainerDevice(const std::string& path,
const std::wstring& local_path)
: Device(path), local_path_(local_path), stfs_(nullptr) {}
STFSContainerDevice::~STFSContainerDevice() { delete stfs_; }
int STFSContainerDevice::Init() {
mmap_ = MappedMemory::Open(local_path_, MappedMemory::Mode::kRead);
if (!mmap_) {
XELOGE("STFS container could not be mapped");
return 1;
}
stfs_ = new STFS(mmap_.get());
STFS::Error error = stfs_->Load();
if (error != STFS::kSuccess) {
XELOGE("STFS init failed: %d", error);
return 1;
}
// stfs_->Dump();
return 0;
}
std::unique_ptr<Entry> STFSContainerDevice::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("STFSContainerDevice::ResolvePath(%s)", path);
STFSEntry* stfs_entry = stfs_->root_entry();
// Walk the path, one separator at a time.
auto path_parts = xe::split_path(path);
for (auto& part : path_parts) {
stfs_entry = stfs_entry->GetChild(part.c_str());
if (!stfs_entry) {
// Not found.
return nullptr;
}
}
return std::make_unique<STFSContainerEntry>(this, path, mmap_.get(),
stfs_entry);
}
} // namespace vfs
} // namespace xe