vfs: Use existing type aliases consistently
Makes use of the VirtualDir and VirtualFile aliases across the board instead of having a few isolated places that don't use it.
This commit is contained in:
parent
4e94d0d53a
commit
b1657b8c6b
|
@ -519,15 +519,17 @@ Loader::ResultStatus NCA::GetStatus() const {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> NCA::GetFiles() const {
|
std::vector<VirtualFile> NCA::GetFiles() const {
|
||||||
if (status != Loader::ResultStatus::Success)
|
if (status != Loader::ResultStatus::Success) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> NCA::GetSubdirectories() const {
|
std::vector<VirtualDir> NCA::GetSubdirectories() const {
|
||||||
if (status != Loader::ResultStatus::Success)
|
if (status != Loader::ResultStatus::Success) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +537,7 @@ std::string NCA::GetName() const {
|
||||||
return file->GetName();
|
return file->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> NCA::GetParentDirectory() const {
|
VirtualDir NCA::GetParentDirectory() const {
|
||||||
return file->GetContainingDirectory();
|
return file->GetContainingDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct NCAHeader {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size.");
|
static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size.");
|
||||||
|
|
||||||
inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) {
|
inline bool IsDirectoryExeFS(const VirtualDir& pfs) {
|
||||||
// According to switchbrew, an exefs must only contain these two files:
|
// According to switchbrew, an exefs must only contain these two files:
|
||||||
return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr;
|
return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -104,10 +104,10 @@ public:
|
||||||
|
|
||||||
Loader::ResultStatus GetStatus() const;
|
Loader::ResultStatus GetStatus() const;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
|
std::vector<VirtualFile> GetFiles() const override;
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::shared_ptr<VfsDirectory> GetParentDirectory() const override;
|
VirtualDir GetParentDirectory() const override;
|
||||||
|
|
||||||
NCAContentType GetType() const;
|
NCAContentType GetType() const;
|
||||||
u64 GetTitleId() const;
|
u64 GetTitleId() const;
|
||||||
|
|
|
@ -191,7 +191,7 @@ bool BKTR::Resize(std::size_t new_size) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> BKTR::GetContainingDirectory() const {
|
VirtualDir BKTR::GetContainingDirectory() const {
|
||||||
return base_romfs->GetContainingDirectory();
|
return base_romfs->GetContainingDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
|
|
||||||
bool Resize(std::size_t new_size) override;
|
bool Resize(std::size_t new_size) override;
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override;
|
VirtualDir GetContainingDirectory() const override;
|
||||||
|
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ std::string VfsFile::GetFullPath() const {
|
||||||
return GetContainingDirectory()->GetFullPath() + "/" + GetName();
|
return GetContainingDirectory()->GetFullPath() + "/" + GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(std::string_view path) const {
|
VirtualFile VfsDirectory::GetFileRelative(std::string_view path) const {
|
||||||
auto vec = Common::FS::SplitPathComponents(path);
|
auto vec = Common::FS::SplitPathComponents(path);
|
||||||
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
||||||
vec.end());
|
vec.end());
|
||||||
|
@ -231,7 +231,7 @@ std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(std::string_view path) co
|
||||||
return dir->GetFile(vec.back());
|
return dir->GetFile(vec.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> VfsDirectory::GetFileAbsolute(std::string_view path) const {
|
VirtualFile VfsDirectory::GetFileAbsolute(std::string_view path) const {
|
||||||
if (IsRoot()) {
|
if (IsRoot()) {
|
||||||
return GetFileRelative(path);
|
return GetFileRelative(path);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ std::shared_ptr<VfsFile> VfsDirectory::GetFileAbsolute(std::string_view path) co
|
||||||
return GetParentDirectory()->GetFileAbsolute(path);
|
return GetParentDirectory()->GetFileAbsolute(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryRelative(std::string_view path) const {
|
VirtualDir VfsDirectory::GetDirectoryRelative(std::string_view path) const {
|
||||||
auto vec = Common::FS::SplitPathComponents(path);
|
auto vec = Common::FS::SplitPathComponents(path);
|
||||||
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
||||||
vec.end());
|
vec.end());
|
||||||
|
@ -261,7 +261,7 @@ std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryRelative(std::string_vie
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryAbsolute(std::string_view path) const {
|
VirtualDir VfsDirectory::GetDirectoryAbsolute(std::string_view path) const {
|
||||||
if (IsRoot()) {
|
if (IsRoot()) {
|
||||||
return GetDirectoryRelative(path);
|
return GetDirectoryRelative(path);
|
||||||
}
|
}
|
||||||
|
@ -269,14 +269,14 @@ std::shared_ptr<VfsDirectory> VfsDirectory::GetDirectoryAbsolute(std::string_vie
|
||||||
return GetParentDirectory()->GetDirectoryAbsolute(path);
|
return GetParentDirectory()->GetDirectoryAbsolute(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> VfsDirectory::GetFile(std::string_view name) const {
|
VirtualFile VfsDirectory::GetFile(std::string_view name) const {
|
||||||
const auto& files = GetFiles();
|
const auto& files = GetFiles();
|
||||||
const auto iter = std::find_if(files.begin(), files.end(),
|
const auto iter = std::find_if(files.begin(), files.end(),
|
||||||
[&name](const auto& file1) { return name == file1->GetName(); });
|
[&name](const auto& file1) { return name == file1->GetName(); });
|
||||||
return iter == files.end() ? nullptr : *iter;
|
return iter == files.end() ? nullptr : *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VfsDirectory::GetSubdirectory(std::string_view name) const {
|
VirtualDir VfsDirectory::GetSubdirectory(std::string_view name) const {
|
||||||
const auto& subs = GetSubdirectories();
|
const auto& subs = GetSubdirectories();
|
||||||
const auto iter = std::find_if(subs.begin(), subs.end(),
|
const auto iter = std::find_if(subs.begin(), subs.end(),
|
||||||
[&name](const auto& file1) { return name == file1->GetName(); });
|
[&name](const auto& file1) { return name == file1->GetName(); });
|
||||||
|
@ -301,7 +301,7 @@ std::size_t VfsDirectory::GetSize() const {
|
||||||
return file_total + subdir_total;
|
return file_total + subdir_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> VfsDirectory::CreateFileRelative(std::string_view path) {
|
VirtualFile VfsDirectory::CreateFileRelative(std::string_view path) {
|
||||||
auto vec = Common::FS::SplitPathComponents(path);
|
auto vec = Common::FS::SplitPathComponents(path);
|
||||||
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
||||||
vec.end());
|
vec.end());
|
||||||
|
@ -324,7 +324,7 @@ std::shared_ptr<VfsFile> VfsDirectory::CreateFileRelative(std::string_view path)
|
||||||
return dir->CreateFileRelative(Common::FS::GetPathWithoutTop(path));
|
return dir->CreateFileRelative(Common::FS::GetPathWithoutTop(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> VfsDirectory::CreateFileAbsolute(std::string_view path) {
|
VirtualFile VfsDirectory::CreateFileAbsolute(std::string_view path) {
|
||||||
if (IsRoot()) {
|
if (IsRoot()) {
|
||||||
return CreateFileRelative(path);
|
return CreateFileRelative(path);
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ std::shared_ptr<VfsFile> VfsDirectory::CreateFileAbsolute(std::string_view path)
|
||||||
return GetParentDirectory()->CreateFileAbsolute(path);
|
return GetParentDirectory()->CreateFileAbsolute(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VfsDirectory::CreateDirectoryRelative(std::string_view path) {
|
VirtualDir VfsDirectory::CreateDirectoryRelative(std::string_view path) {
|
||||||
auto vec = Common::FS::SplitPathComponents(path);
|
auto vec = Common::FS::SplitPathComponents(path);
|
||||||
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
|
||||||
vec.end());
|
vec.end());
|
||||||
|
@ -355,7 +355,7 @@ std::shared_ptr<VfsDirectory> VfsDirectory::CreateDirectoryRelative(std::string_
|
||||||
return dir->CreateDirectoryRelative(Common::FS::GetPathWithoutTop(path));
|
return dir->CreateDirectoryRelative(Common::FS::GetPathWithoutTop(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VfsDirectory::CreateDirectoryAbsolute(std::string_view path) {
|
VirtualDir VfsDirectory::CreateDirectoryAbsolute(std::string_view path) {
|
||||||
if (IsRoot()) {
|
if (IsRoot()) {
|
||||||
return CreateDirectoryRelative(path);
|
return CreateDirectoryRelative(path);
|
||||||
}
|
}
|
||||||
|
@ -446,27 +446,27 @@ bool ReadOnlyVfsDirectory::IsReadable() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> ReadOnlyVfsDirectory::CreateSubdirectory(std::string_view name) {
|
VirtualDir ReadOnlyVfsDirectory::CreateSubdirectory(std::string_view name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> ReadOnlyVfsDirectory::CreateFile(std::string_view name) {
|
VirtualFile ReadOnlyVfsDirectory::CreateFile(std::string_view name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> ReadOnlyVfsDirectory::CreateFileAbsolute(std::string_view path) {
|
VirtualFile ReadOnlyVfsDirectory::CreateFileAbsolute(std::string_view path) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> ReadOnlyVfsDirectory::CreateFileRelative(std::string_view path) {
|
VirtualFile ReadOnlyVfsDirectory::CreateFileRelative(std::string_view path) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> ReadOnlyVfsDirectory::CreateDirectoryAbsolute(std::string_view path) {
|
VirtualDir ReadOnlyVfsDirectory::CreateDirectoryAbsolute(std::string_view path) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> ReadOnlyVfsDirectory::CreateDirectoryRelative(std::string_view path) {
|
VirtualDir ReadOnlyVfsDirectory::CreateDirectoryRelative(std::string_view path) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
// Resizes the file to new_size. Returns whether or not the operation was successful.
|
// Resizes the file to new_size. Returns whether or not the operation was successful.
|
||||||
virtual bool Resize(std::size_t new_size) = 0;
|
virtual bool Resize(std::size_t new_size) = 0;
|
||||||
// Gets a pointer to the directory containing this file, returning nullptr if there is none.
|
// Gets a pointer to the directory containing this file, returning nullptr if there is none.
|
||||||
virtual std::shared_ptr<VfsDirectory> GetContainingDirectory() const = 0;
|
virtual VirtualDir GetContainingDirectory() const = 0;
|
||||||
|
|
||||||
// Returns whether or not the file can be written to.
|
// Returns whether or not the file can be written to.
|
||||||
virtual bool IsWritable() const = 0;
|
virtual bool IsWritable() const = 0;
|
||||||
|
@ -183,27 +183,27 @@ public:
|
||||||
|
|
||||||
// Retrives the file located at path as if the current directory was root. Returns nullptr if
|
// Retrives the file located at path as if the current directory was root. Returns nullptr if
|
||||||
// not found.
|
// not found.
|
||||||
virtual std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const;
|
virtual VirtualFile GetFileRelative(std::string_view path) const;
|
||||||
// Calls GetFileRelative(path) on the root of the current directory.
|
// Calls GetFileRelative(path) on the root of the current directory.
|
||||||
virtual std::shared_ptr<VfsFile> GetFileAbsolute(std::string_view path) const;
|
virtual VirtualFile GetFileAbsolute(std::string_view path) const;
|
||||||
|
|
||||||
// Retrives the directory located at path as if the current directory was root. Returns nullptr
|
// Retrives the directory located at path as if the current directory was root. Returns nullptr
|
||||||
// if not found.
|
// if not found.
|
||||||
virtual std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const;
|
virtual VirtualDir GetDirectoryRelative(std::string_view path) const;
|
||||||
// Calls GetDirectoryRelative(path) on the root of the current directory.
|
// Calls GetDirectoryRelative(path) on the root of the current directory.
|
||||||
virtual std::shared_ptr<VfsDirectory> GetDirectoryAbsolute(std::string_view path) const;
|
virtual VirtualDir GetDirectoryAbsolute(std::string_view path) const;
|
||||||
|
|
||||||
// Returns a vector containing all of the files in this directory.
|
// Returns a vector containing all of the files in this directory.
|
||||||
virtual std::vector<std::shared_ptr<VfsFile>> GetFiles() const = 0;
|
virtual std::vector<VirtualFile> GetFiles() const = 0;
|
||||||
// Returns the file with filename matching name. Returns nullptr if directory dosen't have a
|
// Returns the file with filename matching name. Returns nullptr if directory dosen't have a
|
||||||
// file with name.
|
// file with name.
|
||||||
virtual std::shared_ptr<VfsFile> GetFile(std::string_view name) const;
|
virtual VirtualFile GetFile(std::string_view name) const;
|
||||||
|
|
||||||
// Returns a vector containing all of the subdirectories in this directory.
|
// Returns a vector containing all of the subdirectories in this directory.
|
||||||
virtual std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const = 0;
|
virtual std::vector<VirtualDir> GetSubdirectories() const = 0;
|
||||||
// Returns the directory with name matching name. Returns nullptr if directory dosen't have a
|
// Returns the directory with name matching name. Returns nullptr if directory dosen't have a
|
||||||
// directory with name.
|
// directory with name.
|
||||||
virtual std::shared_ptr<VfsDirectory> GetSubdirectory(std::string_view name) const;
|
virtual VirtualDir GetSubdirectory(std::string_view name) const;
|
||||||
|
|
||||||
// Returns whether or not the directory can be written to.
|
// Returns whether or not the directory can be written to.
|
||||||
virtual bool IsWritable() const = 0;
|
virtual bool IsWritable() const = 0;
|
||||||
|
@ -219,31 +219,31 @@ public:
|
||||||
virtual std::size_t GetSize() const;
|
virtual std::size_t GetSize() const;
|
||||||
// Returns the parent directory of this directory. Returns nullptr if this directory is root or
|
// Returns the parent directory of this directory. Returns nullptr if this directory is root or
|
||||||
// has no parent.
|
// has no parent.
|
||||||
virtual std::shared_ptr<VfsDirectory> GetParentDirectory() const = 0;
|
virtual VirtualDir GetParentDirectory() const = 0;
|
||||||
|
|
||||||
// Creates a new subdirectory with name name. Returns a pointer to the new directory or nullptr
|
// Creates a new subdirectory with name name. Returns a pointer to the new directory or nullptr
|
||||||
// if the operation failed.
|
// if the operation failed.
|
||||||
virtual std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) = 0;
|
virtual VirtualDir CreateSubdirectory(std::string_view name) = 0;
|
||||||
// Creates a new file with name name. Returns a pointer to the new file or nullptr if the
|
// Creates a new file with name name. Returns a pointer to the new file or nullptr if the
|
||||||
// operation failed.
|
// operation failed.
|
||||||
virtual std::shared_ptr<VfsFile> CreateFile(std::string_view name) = 0;
|
virtual VirtualFile CreateFile(std::string_view name) = 0;
|
||||||
|
|
||||||
// Creates a new file at the path relative to this directory. Also creates directories if
|
// Creates a new file at the path relative to this directory. Also creates directories if
|
||||||
// they do not exist and is supported by this implementation. Returns nullptr on any failure.
|
// they do not exist and is supported by this implementation. Returns nullptr on any failure.
|
||||||
virtual std::shared_ptr<VfsFile> CreateFileRelative(std::string_view path);
|
virtual VirtualFile CreateFileRelative(std::string_view path);
|
||||||
|
|
||||||
// Creates a new file at the path relative to root of this directory. Also creates directories
|
// Creates a new file at the path relative to root of this directory. Also creates directories
|
||||||
// if they do not exist and is supported by this implementation. Returns nullptr on any failure.
|
// if they do not exist and is supported by this implementation. Returns nullptr on any failure.
|
||||||
virtual std::shared_ptr<VfsFile> CreateFileAbsolute(std::string_view path);
|
virtual VirtualFile CreateFileAbsolute(std::string_view path);
|
||||||
|
|
||||||
// Creates a new directory at the path relative to this directory. Also creates directories if
|
// Creates a new directory at the path relative to this directory. Also creates directories if
|
||||||
// they do not exist and is supported by this implementation. Returns nullptr on any failure.
|
// they do not exist and is supported by this implementation. Returns nullptr on any failure.
|
||||||
virtual std::shared_ptr<VfsDirectory> CreateDirectoryRelative(std::string_view path);
|
virtual VirtualDir CreateDirectoryRelative(std::string_view path);
|
||||||
|
|
||||||
// Creates a new directory at the path relative to root of this directory. Also creates
|
// Creates a new directory at the path relative to root of this directory. Also creates
|
||||||
// directories if they do not exist and is supported by this implementation. Returns nullptr on
|
// directories if they do not exist and is supported by this implementation. Returns nullptr on
|
||||||
// any failure.
|
// any failure.
|
||||||
virtual std::shared_ptr<VfsDirectory> CreateDirectoryAbsolute(std::string_view path);
|
virtual VirtualDir CreateDirectoryAbsolute(std::string_view path);
|
||||||
|
|
||||||
// Deletes the subdirectory with the given name and returns true on success.
|
// Deletes the subdirectory with the given name and returns true on success.
|
||||||
virtual bool DeleteSubdirectory(std::string_view name) = 0;
|
virtual bool DeleteSubdirectory(std::string_view name) = 0;
|
||||||
|
@ -280,12 +280,12 @@ class ReadOnlyVfsDirectory : public VfsDirectory {
|
||||||
public:
|
public:
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
|
VirtualDir CreateSubdirectory(std::string_view name) override;
|
||||||
std::shared_ptr<VfsFile> CreateFile(std::string_view name) override;
|
VirtualFile CreateFile(std::string_view name) override;
|
||||||
std::shared_ptr<VfsFile> CreateFileAbsolute(std::string_view path) override;
|
VirtualFile CreateFileAbsolute(std::string_view path) override;
|
||||||
std::shared_ptr<VfsFile> CreateFileRelative(std::string_view path) override;
|
VirtualFile CreateFileRelative(std::string_view path) override;
|
||||||
std::shared_ptr<VfsDirectory> CreateDirectoryAbsolute(std::string_view path) override;
|
VirtualDir CreateDirectoryAbsolute(std::string_view path) override;
|
||||||
std::shared_ptr<VfsDirectory> CreateDirectoryRelative(std::string_view path) override;
|
VirtualDir CreateDirectoryRelative(std::string_view path) override;
|
||||||
bool DeleteSubdirectory(std::string_view name) override;
|
bool DeleteSubdirectory(std::string_view name) override;
|
||||||
bool DeleteSubdirectoryRecursive(std::string_view name) override;
|
bool DeleteSubdirectoryRecursive(std::string_view name) override;
|
||||||
bool CleanSubdirectoryRecursive(std::string_view name) override;
|
bool CleanSubdirectoryRecursive(std::string_view name) override;
|
||||||
|
|
|
@ -46,7 +46,7 @@ VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(std::vector<VirtualFile> f
|
||||||
if (files.size() == 1)
|
if (files.size() == 1)
|
||||||
return files[0];
|
return files[0];
|
||||||
|
|
||||||
return std::shared_ptr<VfsFile>(new ConcatenatedVfsFile(std::move(files), std::move(name)));
|
return VirtualFile(new ConcatenatedVfsFile(std::move(files), std::move(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte,
|
VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte,
|
||||||
|
@ -71,20 +71,23 @@ VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte,
|
||||||
if (files.begin()->first != 0)
|
if (files.begin()->first != 0)
|
||||||
files.emplace(0, std::make_shared<StaticVfsFile>(filler_byte, files.begin()->first));
|
files.emplace(0, std::make_shared<StaticVfsFile>(filler_byte, files.begin()->first));
|
||||||
|
|
||||||
return std::shared_ptr<VfsFile>(new ConcatenatedVfsFile(std::move(files), std::move(name)));
|
return VirtualFile(new ConcatenatedVfsFile(std::move(files), std::move(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ConcatenatedVfsFile::GetName() const {
|
std::string ConcatenatedVfsFile::GetName() const {
|
||||||
if (files.empty())
|
if (files.empty()) {
|
||||||
return "";
|
return "";
|
||||||
if (!name.empty())
|
}
|
||||||
|
if (!name.empty()) {
|
||||||
return name;
|
return name;
|
||||||
|
}
|
||||||
return files.begin()->second->GetName();
|
return files.begin()->second->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t ConcatenatedVfsFile::GetSize() const {
|
std::size_t ConcatenatedVfsFile::GetSize() const {
|
||||||
if (files.empty())
|
if (files.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
return files.rbegin()->first + files.rbegin()->second->GetSize();
|
return files.rbegin()->first + files.rbegin()->second->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +95,10 @@ bool ConcatenatedVfsFile::Resize(std::size_t new_size) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> ConcatenatedVfsFile::GetContainingDirectory() const {
|
VirtualDir ConcatenatedVfsFile::GetContainingDirectory() const {
|
||||||
if (files.empty())
|
if (files.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
return files.begin()->second->GetContainingDirectory();
|
return files.begin()->second->GetContainingDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::size_t GetSize() const override;
|
std::size_t GetSize() const override;
|
||||||
bool Resize(std::size_t new_size) override;
|
bool Resize(std::size_t new_size) override;
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override;
|
VirtualDir GetContainingDirectory() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
||||||
|
|
|
@ -20,10 +20,10 @@ VirtualDir LayeredVfsDirectory::MakeLayeredDirectory(std::vector<VirtualDir> dir
|
||||||
if (dirs.size() == 1)
|
if (dirs.size() == 1)
|
||||||
return dirs[0];
|
return dirs[0];
|
||||||
|
|
||||||
return std::shared_ptr<VfsDirectory>(new LayeredVfsDirectory(std::move(dirs), std::move(name)));
|
return VirtualDir(new LayeredVfsDirectory(std::move(dirs), std::move(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> LayeredVfsDirectory::GetFileRelative(std::string_view path) const {
|
VirtualFile LayeredVfsDirectory::GetFileRelative(std::string_view path) const {
|
||||||
for (const auto& layer : dirs) {
|
for (const auto& layer : dirs) {
|
||||||
const auto file = layer->GetFileRelative(path);
|
const auto file = layer->GetFileRelative(path);
|
||||||
if (file != nullptr)
|
if (file != nullptr)
|
||||||
|
@ -33,23 +33,23 @@ std::shared_ptr<VfsFile> LayeredVfsDirectory::GetFileRelative(std::string_view p
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> LayeredVfsDirectory::GetDirectoryRelative(
|
VirtualDir LayeredVfsDirectory::GetDirectoryRelative(std::string_view path) const {
|
||||||
std::string_view path) const {
|
|
||||||
std::vector<VirtualDir> out;
|
std::vector<VirtualDir> out;
|
||||||
for (const auto& layer : dirs) {
|
for (const auto& layer : dirs) {
|
||||||
auto dir = layer->GetDirectoryRelative(path);
|
auto dir = layer->GetDirectoryRelative(path);
|
||||||
if (dir != nullptr)
|
if (dir != nullptr) {
|
||||||
out.push_back(std::move(dir));
|
out.push_back(std::move(dir));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MakeLayeredDirectory(std::move(out));
|
return MakeLayeredDirectory(std::move(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> LayeredVfsDirectory::GetFile(std::string_view name) const {
|
VirtualFile LayeredVfsDirectory::GetFile(std::string_view name) const {
|
||||||
return GetFileRelative(name);
|
return GetFileRelative(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> LayeredVfsDirectory::GetSubdirectory(std::string_view name) const {
|
VirtualDir LayeredVfsDirectory::GetSubdirectory(std::string_view name) const {
|
||||||
return GetDirectoryRelative(name);
|
return GetDirectoryRelative(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ std::string LayeredVfsDirectory::GetFullPath() const {
|
||||||
return dirs[0]->GetFullPath();
|
return dirs[0]->GetFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> LayeredVfsDirectory::GetFiles() const {
|
std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const {
|
||||||
std::vector<VirtualFile> out;
|
std::vector<VirtualFile> out;
|
||||||
for (const auto& layer : dirs) {
|
for (const auto& layer : dirs) {
|
||||||
for (const auto& file : layer->GetFiles()) {
|
for (const auto& file : layer->GetFiles()) {
|
||||||
|
@ -72,7 +72,7 @@ std::vector<std::shared_ptr<VfsFile>> LayeredVfsDirectory::GetFiles() const {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> LayeredVfsDirectory::GetSubdirectories() const {
|
std::vector<VirtualDir> LayeredVfsDirectory::GetSubdirectories() const {
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
for (const auto& layer : dirs) {
|
for (const auto& layer : dirs) {
|
||||||
for (const auto& sd : layer->GetSubdirectories()) {
|
for (const auto& sd : layer->GetSubdirectories()) {
|
||||||
|
@ -101,15 +101,15 @@ std::string LayeredVfsDirectory::GetName() const {
|
||||||
return name.empty() ? dirs[0]->GetName() : name;
|
return name.empty() ? dirs[0]->GetName() : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> LayeredVfsDirectory::GetParentDirectory() const {
|
VirtualDir LayeredVfsDirectory::GetParentDirectory() const {
|
||||||
return dirs[0]->GetParentDirectory();
|
return dirs[0]->GetParentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> LayeredVfsDirectory::CreateSubdirectory(std::string_view name) {
|
VirtualDir LayeredVfsDirectory::CreateSubdirectory(std::string_view name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> LayeredVfsDirectory::CreateFile(std::string_view name) {
|
VirtualFile LayeredVfsDirectory::CreateFile(std::string_view name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,20 +21,20 @@ public:
|
||||||
/// Wrapper function to allow for more efficient handling of dirs.size() == 0, 1 cases.
|
/// Wrapper function to allow for more efficient handling of dirs.size() == 0, 1 cases.
|
||||||
static VirtualDir MakeLayeredDirectory(std::vector<VirtualDir> dirs, std::string name = "");
|
static VirtualDir MakeLayeredDirectory(std::vector<VirtualDir> dirs, std::string name = "");
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const override;
|
VirtualFile GetFileRelative(std::string_view path) const override;
|
||||||
std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const override;
|
VirtualDir GetDirectoryRelative(std::string_view path) const override;
|
||||||
std::shared_ptr<VfsFile> GetFile(std::string_view name) const override;
|
VirtualFile GetFile(std::string_view name) const override;
|
||||||
std::shared_ptr<VfsDirectory> GetSubdirectory(std::string_view name) const override;
|
VirtualDir GetSubdirectory(std::string_view name) const override;
|
||||||
std::string GetFullPath() const override;
|
std::string GetFullPath() const override;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
|
std::vector<VirtualFile> GetFiles() const override;
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::shared_ptr<VfsDirectory> GetParentDirectory() const override;
|
VirtualDir GetParentDirectory() const override;
|
||||||
std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
|
VirtualDir CreateSubdirectory(std::string_view name) override;
|
||||||
std::shared_ptr<VfsFile> CreateFile(std::string_view name) override;
|
VirtualFile CreateFile(std::string_view name) override;
|
||||||
bool DeleteSubdirectory(std::string_view name) override;
|
bool DeleteSubdirectory(std::string_view name) override;
|
||||||
bool DeleteFile(std::string_view name) override;
|
bool DeleteFile(std::string_view name) override;
|
||||||
bool Rename(std::string_view name) override;
|
bool Rename(std::string_view name) override;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
OffsetVfsFile::OffsetVfsFile(std::shared_ptr<VfsFile> file_, std::size_t size_, std::size_t offset_,
|
OffsetVfsFile::OffsetVfsFile(VirtualFile file_, std::size_t size_, std::size_t offset_,
|
||||||
std::string name_, VirtualDir parent_)
|
std::string name_, VirtualDir parent_)
|
||||||
: file(file_), offset(offset_), size(size_), name(std::move(name_)),
|
: file(file_), offset(offset_), size(size_), name(std::move(name_)),
|
||||||
parent(parent_ == nullptr ? file->GetContainingDirectory() : std::move(parent_)) {}
|
parent(parent_ == nullptr ? file->GetContainingDirectory() : std::move(parent_)) {}
|
||||||
|
@ -37,7 +37,7 @@ bool OffsetVfsFile::Resize(std::size_t new_size) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> OffsetVfsFile::GetContainingDirectory() const {
|
VirtualDir OffsetVfsFile::GetContainingDirectory() const {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,14 @@ namespace FileSys {
|
||||||
// the size of this wrapper.
|
// the size of this wrapper.
|
||||||
class OffsetVfsFile : public VfsFile {
|
class OffsetVfsFile : public VfsFile {
|
||||||
public:
|
public:
|
||||||
OffsetVfsFile(std::shared_ptr<VfsFile> file, std::size_t size, std::size_t offset = 0,
|
OffsetVfsFile(VirtualFile file, std::size_t size, std::size_t offset = 0,
|
||||||
std::string new_name = "", VirtualDir new_parent = nullptr);
|
std::string new_name = "", VirtualDir new_parent = nullptr);
|
||||||
~OffsetVfsFile() override;
|
~OffsetVfsFile() override;
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::size_t GetSize() const override;
|
std::size_t GetSize() const override;
|
||||||
bool Resize(std::size_t new_size) override;
|
bool Resize(std::size_t new_size) override;
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override;
|
VirtualDir GetContainingDirectory() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
||||||
|
@ -42,7 +42,7 @@ public:
|
||||||
private:
|
private:
|
||||||
std::size_t TrimToFit(std::size_t r_size, std::size_t r_offset) const;
|
std::size_t TrimToFit(std::size_t r_size, std::size_t r_offset) const;
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> file;
|
VirtualFile file;
|
||||||
std::size_t offset;
|
std::size_t offset;
|
||||||
std::size_t size;
|
std::size_t size;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
|
@ -267,7 +267,7 @@ bool RealVfsFile::Resize(std::size_t new_size) {
|
||||||
return backing->Resize(new_size);
|
return backing->Resize(new_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> RealVfsFile::GetContainingDirectory() const {
|
VirtualDir RealVfsFile::GetContainingDirectory() const {
|
||||||
return base.OpenDirectory(parent_path, perms);
|
return base.OpenDirectory(parent_path, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string&
|
||||||
|
|
||||||
RealVfsDirectory::~RealVfsDirectory() = default;
|
RealVfsDirectory::~RealVfsDirectory() = default;
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> RealVfsDirectory::GetFileRelative(std::string_view path) const {
|
VirtualFile RealVfsDirectory::GetFileRelative(std::string_view path) const {
|
||||||
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
||||||
if (!FS::Exists(full_path) || FS::IsDirectory(full_path)) {
|
if (!FS::Exists(full_path) || FS::IsDirectory(full_path)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -364,7 +364,7 @@ std::shared_ptr<VfsFile> RealVfsDirectory::GetFileRelative(std::string_view path
|
||||||
return base.OpenFile(full_path, perms);
|
return base.OpenFile(full_path, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> RealVfsDirectory::GetDirectoryRelative(std::string_view path) const {
|
VirtualDir RealVfsDirectory::GetDirectoryRelative(std::string_view path) const {
|
||||||
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
||||||
if (!FS::Exists(full_path) || !FS::IsDirectory(full_path)) {
|
if (!FS::Exists(full_path) || !FS::IsDirectory(full_path)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -372,20 +372,20 @@ std::shared_ptr<VfsDirectory> RealVfsDirectory::GetDirectoryRelative(std::string
|
||||||
return base.OpenDirectory(full_path, perms);
|
return base.OpenDirectory(full_path, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> RealVfsDirectory::GetFile(std::string_view name) const {
|
VirtualFile RealVfsDirectory::GetFile(std::string_view name) const {
|
||||||
return GetFileRelative(name);
|
return GetFileRelative(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> RealVfsDirectory::GetSubdirectory(std::string_view name) const {
|
VirtualDir RealVfsDirectory::GetSubdirectory(std::string_view name) const {
|
||||||
return GetDirectoryRelative(name);
|
return GetDirectoryRelative(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> RealVfsDirectory::CreateFileRelative(std::string_view path) {
|
VirtualFile RealVfsDirectory::CreateFileRelative(std::string_view path) {
|
||||||
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
||||||
return base.CreateFile(full_path, perms);
|
return base.CreateFile(full_path, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> RealVfsDirectory::CreateDirectoryRelative(std::string_view path) {
|
VirtualDir RealVfsDirectory::CreateDirectoryRelative(std::string_view path) {
|
||||||
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
const auto full_path = FS::SanitizePath(this->path + DIR_SEP + std::string(path));
|
||||||
return base.CreateDirectory(full_path, perms);
|
return base.CreateDirectory(full_path, perms);
|
||||||
}
|
}
|
||||||
|
@ -395,11 +395,11 @@ bool RealVfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) {
|
||||||
return base.DeleteDirectory(full_path);
|
return base.DeleteDirectory(full_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> RealVfsDirectory::GetFiles() const {
|
std::vector<VirtualFile> RealVfsDirectory::GetFiles() const {
|
||||||
return IterateEntries<RealVfsFile, VfsFile>();
|
return IterateEntries<RealVfsFile, VfsFile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> RealVfsDirectory::GetSubdirectories() const {
|
std::vector<VirtualDir> RealVfsDirectory::GetSubdirectories() const {
|
||||||
return IterateEntries<RealVfsDirectory, VfsDirectory>();
|
return IterateEntries<RealVfsDirectory, VfsDirectory>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ std::string RealVfsDirectory::GetName() const {
|
||||||
return path_components.back();
|
return path_components.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> RealVfsDirectory::GetParentDirectory() const {
|
VirtualDir RealVfsDirectory::GetParentDirectory() const {
|
||||||
if (path_components.size() <= 1) {
|
if (path_components.size() <= 1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -423,12 +423,12 @@ std::shared_ptr<VfsDirectory> RealVfsDirectory::GetParentDirectory() const {
|
||||||
return base.OpenDirectory(parent_path, perms);
|
return base.OpenDirectory(parent_path, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> RealVfsDirectory::CreateSubdirectory(std::string_view name) {
|
VirtualDir RealVfsDirectory::CreateSubdirectory(std::string_view name) {
|
||||||
const std::string subdir_path = (path + DIR_SEP).append(name);
|
const std::string subdir_path = (path + DIR_SEP).append(name);
|
||||||
return base.CreateDirectory(subdir_path, perms);
|
return base.CreateDirectory(subdir_path, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> RealVfsDirectory::CreateFile(std::string_view name) {
|
VirtualFile RealVfsDirectory::CreateFile(std::string_view name) {
|
||||||
const std::string file_path = (path + DIR_SEP).append(name);
|
const std::string file_path = (path + DIR_SEP).append(name);
|
||||||
return base.CreateFile(file_path, perms);
|
return base.CreateFile(file_path, perms);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::size_t GetSize() const override;
|
std::size_t GetSize() const override;
|
||||||
bool Resize(std::size_t new_size) override;
|
bool Resize(std::size_t new_size) override;
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override;
|
VirtualDir GetContainingDirectory() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
||||||
|
@ -79,21 +79,21 @@ class RealVfsDirectory : public VfsDirectory {
|
||||||
public:
|
public:
|
||||||
~RealVfsDirectory() override;
|
~RealVfsDirectory() override;
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const override;
|
VirtualFile GetFileRelative(std::string_view path) const override;
|
||||||
std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const override;
|
VirtualDir GetDirectoryRelative(std::string_view path) const override;
|
||||||
std::shared_ptr<VfsFile> GetFile(std::string_view name) const override;
|
VirtualFile GetFile(std::string_view name) const override;
|
||||||
std::shared_ptr<VfsDirectory> GetSubdirectory(std::string_view name) const override;
|
VirtualDir GetSubdirectory(std::string_view name) const override;
|
||||||
std::shared_ptr<VfsFile> CreateFileRelative(std::string_view path) override;
|
VirtualFile CreateFileRelative(std::string_view path) override;
|
||||||
std::shared_ptr<VfsDirectory> CreateDirectoryRelative(std::string_view path) override;
|
VirtualDir CreateDirectoryRelative(std::string_view path) override;
|
||||||
bool DeleteSubdirectoryRecursive(std::string_view name) override;
|
bool DeleteSubdirectoryRecursive(std::string_view name) override;
|
||||||
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
|
std::vector<VirtualFile> GetFiles() const override;
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::shared_ptr<VfsDirectory> GetParentDirectory() const override;
|
VirtualDir GetParentDirectory() const override;
|
||||||
std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
|
VirtualDir CreateSubdirectory(std::string_view name) override;
|
||||||
std::shared_ptr<VfsFile> CreateFile(std::string_view name) override;
|
VirtualFile CreateFile(std::string_view name) override;
|
||||||
bool DeleteSubdirectory(std::string_view name) override;
|
bool DeleteSubdirectory(std::string_view name) override;
|
||||||
bool DeleteFile(std::string_view name) override;
|
bool DeleteFile(std::string_view name) override;
|
||||||
bool Rename(std::string_view name) override;
|
bool Rename(std::string_view name) override;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override {
|
VirtualDir GetContainingDirectory() const override {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ bool VectorVfsFile::Resize(size_t new_size) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VectorVfsFile::GetContainingDirectory() const {
|
VirtualDir VectorVfsFile::GetContainingDirectory() const {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ VectorVfsDirectory::VectorVfsDirectory(std::vector<VirtualFile> files_,
|
||||||
|
|
||||||
VectorVfsDirectory::~VectorVfsDirectory() = default;
|
VectorVfsDirectory::~VectorVfsDirectory() = default;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> VectorVfsDirectory::GetFiles() const {
|
std::vector<VirtualFile> VectorVfsDirectory::GetFiles() const {
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> VectorVfsDirectory::GetSubdirectories() const {
|
std::vector<VirtualDir> VectorVfsDirectory::GetSubdirectories() const {
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ std::string VectorVfsDirectory::GetName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VectorVfsDirectory::GetParentDirectory() const {
|
VirtualDir VectorVfsDirectory::GetParentDirectory() const {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +116,11 @@ bool VectorVfsDirectory::Rename(std::string_view name_) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> VectorVfsDirectory::CreateSubdirectory(std::string_view name) {
|
VirtualDir VectorVfsDirectory::CreateSubdirectory(std::string_view name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsFile> VectorVfsDirectory::CreateFile(std::string_view name) {
|
VirtualFile VectorVfsDirectory::CreateFile(std::string_view name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override {
|
VirtualDir GetContainingDirectory() const override {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::size_t GetSize() const override;
|
std::size_t GetSize() const override;
|
||||||
bool Resize(std::size_t new_size) override;
|
bool Resize(std::size_t new_size) override;
|
||||||
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override;
|
VirtualDir GetContainingDirectory() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
|
||||||
|
@ -106,17 +106,17 @@ public:
|
||||||
VirtualDir parent = nullptr);
|
VirtualDir parent = nullptr);
|
||||||
~VectorVfsDirectory() override;
|
~VectorVfsDirectory() override;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
|
std::vector<VirtualFile> GetFiles() const override;
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::shared_ptr<VfsDirectory> GetParentDirectory() const override;
|
VirtualDir GetParentDirectory() const override;
|
||||||
bool DeleteSubdirectory(std::string_view name) override;
|
bool DeleteSubdirectory(std::string_view name) override;
|
||||||
bool DeleteFile(std::string_view name) override;
|
bool DeleteFile(std::string_view name) override;
|
||||||
bool Rename(std::string_view name) override;
|
bool Rename(std::string_view name) override;
|
||||||
std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
|
VirtualDir CreateSubdirectory(std::string_view name) override;
|
||||||
std::shared_ptr<VfsFile> CreateFile(std::string_view name) override;
|
VirtualFile CreateFile(std::string_view name) override;
|
||||||
|
|
||||||
virtual void AddFile(VirtualFile file);
|
virtual void AddFile(VirtualFile file);
|
||||||
virtual void AddDirectory(VirtualDir dir);
|
virtual void AddDirectory(VirtualDir dir);
|
||||||
|
|
|
@ -152,11 +152,11 @@ NAXContentType NAX::GetContentType() const {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> NAX::GetFiles() const {
|
std::vector<VirtualFile> NAX::GetFiles() const {
|
||||||
return {dec_file};
|
return {dec_file};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> NAX::GetSubdirectories() const {
|
std::vector<VirtualDir> NAX::GetSubdirectories() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ std::string NAX::GetName() const {
|
||||||
return file->GetName();
|
return file->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> NAX::GetParentDirectory() const {
|
VirtualDir NAX::GetParentDirectory() const {
|
||||||
return file->GetContainingDirectory();
|
return file->GetContainingDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,13 @@ public:
|
||||||
|
|
||||||
NAXContentType GetContentType() const;
|
NAXContentType GetContentType() const;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
|
std::vector<VirtualFile> GetFiles() const override;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
|
|
||||||
std::shared_ptr<VfsDirectory> GetParentDirectory() const override;
|
VirtualDir GetParentDirectory() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Loader::ResultStatus Parse(std::string_view path);
|
Loader::ResultStatus Parse(std::string_view path);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
* @param file std::shared_ptr<VfsFile> open file
|
* @param file open file
|
||||||
* @return FileType found, or FileType::Error if this loader doesn't know it
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
Reference in New Issue