early-access version 3669

This commit is contained in:
pineappleEA
2023-06-13 09:04:01 +02:00
parent abe9c2ff0d
commit fbb35fcc7e
23 changed files with 154 additions and 230 deletions

View File

@@ -4,7 +4,7 @@
#pragma once
#include <string_view>
#include "common/intrusive_list.h"
#include <boost/container/flat_map.hpp>
#include "core/file_sys/mode.h"
#include "core/file_sys/vfs.h"
@@ -14,11 +14,6 @@ class IOFile;
namespace FileSys {
struct FileReference : public Common::IntrusiveListBaseNode<FileReference> {
std::shared_ptr<Common::FS::IOFile> file{};
};
class RealVfsFile;
class RealVfsFilesystem : public VfsFilesystem {
public:
RealVfsFilesystem();
@@ -40,20 +35,7 @@ public:
bool DeleteDirectory(std::string_view path) override;
private:
using ReferenceListType = Common::IntrusiveListBaseTraits<FileReference>::ListType;
ReferenceListType open_references;
ReferenceListType closed_references;
size_t num_open_files{};
private:
friend class RealVfsFile;
void RefreshReference(const std::string& path, Mode perms, FileReference& reference);
void DropReference(std::unique_ptr<FileReference>&& reference);
void EvictSingleReference();
private:
void InsertReferenceIntoList(FileReference& reference);
void RemoveReferenceFromList(FileReference& reference);
boost::container::flat_map<std::string, std::weak_ptr<Common::FS::IOFile>> cache;
};
// An implementation of VfsFile that represents a file on the user's computer.
@@ -75,11 +57,13 @@ public:
bool Rename(std::string_view name) override;
private:
RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference,
RealVfsFile(RealVfsFilesystem& base, std::shared_ptr<Common::FS::IOFile> backing,
const std::string& path, Mode perms = Mode::Read);
void Close();
RealVfsFilesystem& base;
std::unique_ptr<FileReference> reference;
std::shared_ptr<Common::FS::IOFile> backing;
std::string path;
std::string parent_path;
std::vector<std::string> path_components;