vfs_layered.h 1.8 KB

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