vfs_layered.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include "core/file_sys/vfs.h"
  6. namespace FileSys {
  7. // Class that stacks multiple VfsDirectories on top of each other, attempting to read from the first
  8. // one and falling back to the one after. The highest priority directory (overwrites all others)
  9. // should be element 0 in the dirs vector.
  10. class LayeredVfsDirectory : public VfsDirectory {
  11. explicit LayeredVfsDirectory(std::vector<VirtualDir> dirs_, std::string name_);
  12. public:
  13. ~LayeredVfsDirectory() override;
  14. /// Wrapper function to allow for more efficient handling of dirs.size() == 0, 1 cases.
  15. static VirtualDir MakeLayeredDirectory(std::vector<VirtualDir> dirs, std::string name = "");
  16. VirtualFile GetFileRelative(std::string_view path) const override;
  17. VirtualDir GetDirectoryRelative(std::string_view path) const override;
  18. VirtualFile GetFile(std::string_view file_name) const override;
  19. VirtualDir GetSubdirectory(std::string_view subdir_name) const override;
  20. std::string GetFullPath() const override;
  21. std::vector<VirtualFile> GetFiles() const override;
  22. std::vector<VirtualDir> GetSubdirectories() const override;
  23. bool IsWritable() const override;
  24. bool IsReadable() const override;
  25. std::string GetName() const override;
  26. VirtualDir GetParentDirectory() const override;
  27. VirtualDir CreateSubdirectory(std::string_view subdir_name) override;
  28. VirtualFile CreateFile(std::string_view file_name) override;
  29. bool DeleteSubdirectory(std::string_view subdir_name) override;
  30. bool DeleteFile(std::string_view file_name) override;
  31. bool Rename(std::string_view new_name) override;
  32. private:
  33. std::vector<VirtualDir> dirs;
  34. std::string name;
  35. };
  36. } // namespace FileSys