aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/vfs/vfs_real.cpp
diff options
context:
space:
mode:
authordarktux <darktux@y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion>2024-04-05 01:58:29 +0200
committerBriar <205427297+icybriarr@users.noreply.github.com>2025-04-04 03:40:46 +0200
commit616619c8f754dc1a783d91aa5b32f45e8df74172 (patch)
tree4aa2bdd001cbf38b58439f59e62ee7705af6a253 /src/core/file_sys/vfs/vfs_real.cpp
parent19a93a3fd1dd6a7db074d254990db073d62b08e3 (diff)
Port changes from Early Access
Diffstat (limited to 'src/core/file_sys/vfs/vfs_real.cpp')
-rw-r--r--src/core/file_sys/vfs/vfs_real.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/file_sys/vfs/vfs_real.cpp b/src/core/file_sys/vfs/vfs_real.cpp
index 3ad073e4ab..052684e9db 100644
--- a/src/core/file_sys/vfs/vfs_real.cpp
+++ b/src/core/file_sys/vfs/vfs_real.cpp
@@ -76,6 +76,7 @@ VfsEntryType RealVfsFilesystem::GetEntryType(std::string_view path_) const {
}
VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::optional<u64> size,
+ std::optional<std::string> parent_path,
OpenMode perms) {
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
std::scoped_lock lk{list_lock};
@@ -94,14 +95,14 @@ VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::op
this->InsertReferenceIntoListLocked(*reference);
auto file = std::shared_ptr<RealVfsFile>(
- new RealVfsFile(*this, std::move(reference), path, perms, size));
+ new RealVfsFile(*this, std::move(reference), path, perms, size, std::move(parent_path)));
cache[path] = file;
return file;
}
VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) {
- return OpenFileFromEntry(path_, {}, perms);
+ return OpenFileFromEntry(path_, {}, {}, perms);
}
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) {
@@ -268,10 +269,11 @@ void RealVfsFilesystem::RemoveReferenceFromListLocked(FileReference& reference)
}
RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_,
- const std::string& path_, OpenMode perms_, std::optional<u64> size_)
+ const std::string& path_, OpenMode perms_, std::optional<u64> size_,
+ std::optional<std::string> parent_path_)
: base(base_), reference(std::move(reference_)), path(path_),
- parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponentsCopy(path_)),
- size(size_), perms(perms_) {}
+ parent_path(parent_path_ ? std::move(*parent_path_) : FS::GetParentPath(path_)),
+ path_components(FS::SplitPathComponentsCopy(path_)), size(size_), perms(perms_) {}
RealVfsFile::~RealVfsFile() {
base.DropReference(std::move(reference));
@@ -348,7 +350,7 @@ std::vector<VirtualFile> RealVfsDirectory::IterateEntries<RealVfsFile, VfsFile>(
&out](const std::filesystem::directory_entry& entry) {
const auto full_path_string = FS::PathToUTF8String(entry.path());
- out.emplace_back(base.OpenFileFromEntry(full_path_string, entry.file_size(), perms));
+ out.emplace_back(base.OpenFileFromEntry(full_path_string, entry.file_size(), path, perms));
return true;
};