2018-09-20 01:59:44 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include "core/file_sys/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 {
|
2021-05-16 05:46:30 +00:00
|
|
|
explicit LayeredVfsDirectory(std::vector<VirtualDir> dirs_, std::string name_);
|
2018-09-20 01:59:44 +00:00
|
|
|
|
|
|
|
public:
|
2018-09-24 01:50:16 +00:00
|
|
|
~LayeredVfsDirectory() override;
|
|
|
|
|
2018-09-25 21:38:16 +00:00
|
|
|
/// Wrapper function to allow for more efficient handling of dirs.size() == 0, 1 cases.
|
|
|
|
static VirtualDir MakeLayeredDirectory(std::vector<VirtualDir> dirs, std::string name = "");
|
|
|
|
|
2020-12-10 06:31:58 +00:00
|
|
|
VirtualFile GetFileRelative(std::string_view path) const override;
|
|
|
|
VirtualDir GetDirectoryRelative(std::string_view path) const override;
|
2021-05-02 06:34:40 +00:00
|
|
|
VirtualFile GetFile(std::string_view file_name) const override;
|
|
|
|
VirtualDir GetSubdirectory(std::string_view subdir_name) const override;
|
2018-09-20 01:59:44 +00:00
|
|
|
std::string GetFullPath() const override;
|
|
|
|
|
2020-12-10 06:31:58 +00:00
|
|
|
std::vector<VirtualFile> GetFiles() const override;
|
|
|
|
std::vector<VirtualDir> GetSubdirectories() const override;
|
2018-09-20 01:59:44 +00:00
|
|
|
bool IsWritable() const override;
|
|
|
|
bool IsReadable() const override;
|
|
|
|
std::string GetName() const override;
|
2020-12-10 06:31:58 +00:00
|
|
|
VirtualDir GetParentDirectory() const override;
|
2021-05-02 06:34:40 +00:00
|
|
|
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;
|
2018-09-20 01:59:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<VirtualDir> dirs;
|
|
|
|
std::string name;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace FileSys
|