vfs_layered.h 1.9 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. 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. std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const override;
  18. std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const override;
  19. std::shared_ptr<VfsFile> GetFile(std::string_view name) const override;
  20. std::shared_ptr<VfsDirectory> GetSubdirectory(std::string_view name) const override;
  21. std::string GetFullPath() const override;
  22. std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
  23. std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
  24. bool IsWritable() const override;
  25. bool IsReadable() const override;
  26. std::string GetName() const override;
  27. std::shared_ptr<VfsDirectory> GetParentDirectory() const override;
  28. std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
  29. std::shared_ptr<VfsFile> CreateFile(std::string_view name) override;
  30. bool DeleteSubdirectory(std::string_view name) override;
  31. bool DeleteFile(std::string_view name) override;
  32. bool Rename(std::string_view name) override;
  33. private:
  34. std::vector<VirtualDir> dirs;
  35. std::string name;
  36. };
  37. } // namespace FileSys