diff options
author | FearlessTobi <thm.frey@gmail.com> | 2024-01-16 06:23:01 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-01-25 22:40:42 +0100 |
commit | 0f9288e38d80c6c63a545934557501fae40d3d83 (patch) | |
tree | 0643100d2471a1545dbfb447319b6ea26fdd6b63 /src/core/file_sys/vfs/vfs_layered.h | |
parent | fs: Move fsp_srv subclasses to separate files (diff) | |
download | yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.tar yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.tar.gz yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.tar.bz2 yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.tar.lz yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.tar.xz yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.tar.zst yuzu-0f9288e38d80c6c63a545934557501fae40d3d83.zip |
Diffstat (limited to 'src/core/file_sys/vfs/vfs_layered.h')
-rw-r--r-- | src/core/file_sys/vfs/vfs_layered.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/core/file_sys/vfs/vfs_layered.h b/src/core/file_sys/vfs/vfs_layered.h new file mode 100644 index 000000000..0027ffa9a --- /dev/null +++ b/src/core/file_sys/vfs/vfs_layered.h @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <memory> +#include "core/file_sys/vfs/vfs.h" + +namespace FileSys { + +// Class that stacks multiple VfsDirectories on top of each other, attempting to read from the first +// one and falling back to the one after. The highest priority directory (overwrites all others) +// should be element 0 in the dirs vector. +class LayeredVfsDirectory : public VfsDirectory { + explicit LayeredVfsDirectory(std::vector<VirtualDir> dirs_, std::string name_); + +public: + ~LayeredVfsDirectory() override; + + /// Wrapper function to allow for more efficient handling of dirs.size() == 0, 1 cases. + static VirtualDir MakeLayeredDirectory(std::vector<VirtualDir> dirs, std::string name = ""); + + VirtualFile GetFileRelative(std::string_view path) const override; + VirtualDir GetDirectoryRelative(std::string_view path) const override; + VirtualFile GetFile(std::string_view file_name) const override; + VirtualDir GetSubdirectory(std::string_view subdir_name) const override; + std::string GetFullPath() const override; + + std::vector<VirtualFile> GetFiles() const override; + std::vector<VirtualDir> GetSubdirectories() const override; + bool IsWritable() const override; + bool IsReadable() const override; + std::string GetName() const override; + VirtualDir GetParentDirectory() const override; + VirtualDir CreateSubdirectory(std::string_view subdir_name) override; + VirtualFile CreateFile(std::string_view file_name) override; + bool DeleteSubdirectory(std::string_view subdir_name) override; + bool DeleteFile(std::string_view file_name) override; + bool Rename(std::string_view new_name) override; + +private: + std::vector<VirtualDir> dirs; + std::string name; +}; + +} // namespace FileSys |