summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/vfs_real.h
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2023-07-02 00:01:11 +0200
committercomex <comexk@gmail.com>2023-07-02 00:01:11 +0200
commit98685d48e3cb9f25f6919f004ec62cadf33afad2 (patch)
tree9df2ce7f57370641589bfae7196c77b090bcbe0f /src/core/file_sys/vfs_real.h
parentPR feedback + constification (diff)
parentUpdate translations (2023-07-01) (#10972) (diff)
downloadyuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.tar
yuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.tar.gz
yuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.tar.bz2
yuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.tar.lz
yuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.tar.xz
yuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.tar.zst
yuzu-98685d48e3cb9f25f6919f004ec62cadf33afad2.zip
Diffstat (limited to 'src/core/file_sys/vfs_real.h')
-rw-r--r--src/core/file_sys/vfs_real.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/core/file_sys/vfs_real.h b/src/core/file_sys/vfs_real.h
index d8c900e33..26ea7df62 100644
--- a/src/core/file_sys/vfs_real.h
+++ b/src/core/file_sys/vfs_real.h
@@ -4,6 +4,8 @@
#pragma once
#include <map>
+#include <mutex>
+#include <optional>
#include <string_view>
#include "common/intrusive_list.h"
#include "core/file_sys/mode.h"
@@ -20,6 +22,8 @@ struct FileReference : public Common::IntrusiveListBaseNode<FileReference> {
};
class RealVfsFile;
+class RealVfsDirectory;
+
class RealVfsFilesystem : public VfsFilesystem {
public:
RealVfsFilesystem();
@@ -45,17 +49,24 @@ private:
std::map<std::string, std::weak_ptr<VfsFile>, std::less<>> cache;
ReferenceListType open_references;
ReferenceListType closed_references;
+ std::mutex list_lock;
size_t num_open_files{};
private:
friend class RealVfsFile;
- void RefreshReference(const std::string& path, Mode perms, FileReference& reference);
+ std::unique_lock<std::mutex> 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);
+ friend class RealVfsDirectory;
+ VirtualFile OpenFileFromEntry(std::string_view path, std::optional<u64> size,
+ Mode perms = Mode::Read);
+
+private:
+ void EvictSingleReferenceLocked();
+ void InsertReferenceIntoListLocked(FileReference& reference);
+ void RemoveReferenceFromListLocked(FileReference& reference);
};
// An implementation of VfsFile that represents a file on the user's computer.
@@ -78,13 +89,14 @@ public:
private:
RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference,
- const std::string& path, Mode perms = Mode::Read);
+ const std::string& path, Mode perms = Mode::Read, std::optional<u64> size = {});
RealVfsFilesystem& base;
std::unique_ptr<FileReference> reference;
std::string path;
std::string parent_path;
std::vector<std::string> path_components;
+ std::optional<u64> size;
Mode perms;
};