|
|
@ -6,15 +6,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <string_view>
|
|
|
|
#include <string_view>
|
|
|
|
#include <boost/container/flat_map.hpp>
|
|
|
|
#include <boost/container/flat_map.hpp>
|
|
|
|
#include "common/file_util.h"
|
|
|
|
|
|
|
|
#include "core/file_sys/mode.h"
|
|
|
|
#include "core/file_sys/mode.h"
|
|
|
|
#include "core/file_sys/vfs.h"
|
|
|
|
#include "core/file_sys/vfs.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace FileUtil {
|
|
|
|
|
|
|
|
class IOFile;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
namespace FileSys {
|
|
|
|
|
|
|
|
|
|
|
|
class RealVfsFilesystem : public VfsFilesystem {
|
|
|
|
class RealVfsFilesystem : public VfsFilesystem {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
RealVfsFilesystem();
|
|
|
|
RealVfsFilesystem();
|
|
|
|
|
|
|
|
~RealVfsFilesystem() override;
|
|
|
|
|
|
|
|
|
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetName() const override;
|
|
|
|
bool IsReadable() const override;
|
|
|
|
bool IsReadable() const override;
|
|
|
@ -40,10 +44,9 @@ class RealVfsFile : public VfsFile {
|
|
|
|
friend class RealVfsDirectory;
|
|
|
|
friend class RealVfsDirectory;
|
|
|
|
friend class RealVfsFilesystem;
|
|
|
|
friend class RealVfsFilesystem;
|
|
|
|
|
|
|
|
|
|
|
|
RealVfsFile(RealVfsFilesystem& base, std::shared_ptr<FileUtil::IOFile> backing,
|
|
|
|
|
|
|
|
const std::string& path, Mode perms = Mode::Read);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
~RealVfsFile() override;
|
|
|
|
|
|
|
|
|
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetName() const override;
|
|
|
|
size_t GetSize() const override;
|
|
|
|
size_t GetSize() const override;
|
|
|
|
bool Resize(size_t new_size) override;
|
|
|
|
bool Resize(size_t new_size) override;
|
|
|
@ -55,6 +58,9 @@ public:
|
|
|
|
bool Rename(std::string_view name) override;
|
|
|
|
bool Rename(std::string_view name) override;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
RealVfsFile(RealVfsFilesystem& base, std::shared_ptr<FileUtil::IOFile> backing,
|
|
|
|
|
|
|
|
const std::string& path, Mode perms = Mode::Read);
|
|
|
|
|
|
|
|
|
|
|
|
bool Close();
|
|
|
|
bool Close();
|
|
|
|
|
|
|
|
|
|
|
|
RealVfsFilesystem& base;
|
|
|
|
RealVfsFilesystem& base;
|
|
|
@ -70,9 +76,9 @@ private:
|
|
|
|
class RealVfsDirectory : public VfsDirectory {
|
|
|
|
class RealVfsDirectory : public VfsDirectory {
|
|
|
|
friend class RealVfsFilesystem;
|
|
|
|
friend class RealVfsFilesystem;
|
|
|
|
|
|
|
|
|
|
|
|
RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, Mode perms = Mode::Read);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
~RealVfsDirectory() override;
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const override;
|
|
|
|
std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const override;
|
|
|
|
std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const override;
|
|
|
|
std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const override;
|
|
|
|
std::shared_ptr<VfsFile> GetFile(std::string_view name) const override;
|
|
|
|
std::shared_ptr<VfsFile> GetFile(std::string_view name) const override;
|
|
|
@ -97,6 +103,8 @@ protected:
|
|
|
|
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
|
|
|
|
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, Mode perms = Mode::Read);
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, typename R>
|
|
|
|
template <typename T, typename R>
|
|
|
|
std::vector<std::shared_ptr<R>> IterateEntries() const;
|
|
|
|
std::vector<std::shared_ptr<R>> IterateEntries() const;
|
|
|
|
|
|
|
|
|
|
|
|