mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 12:55:38 +01:00
vfs_real: lazily open files
This commit is contained in:
parent
f25236a4d6
commit
0e7eaaba5a
@ -75,16 +75,9 @@ VfsEntryType RealVfsFilesystem::GetEntryType(std::string_view path_) const {
|
|||||||
VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
|
VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
|
||||||
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
|
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
|
||||||
|
|
||||||
this->EvictSingleReference();
|
auto reference = std::make_unique<FileReference>();
|
||||||
|
|
||||||
auto backing = FS::FileOpen(path, ModeFlagsToFileAccessMode(perms), FS::FileType::BinaryFile);
|
|
||||||
if (!backing) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_open_files++;
|
|
||||||
auto reference = std::make_unique<FileReference>(std::move(backing));
|
|
||||||
this->InsertReferenceIntoList(*reference);
|
this->InsertReferenceIntoList(*reference);
|
||||||
|
|
||||||
return std::shared_ptr<RealVfsFile>(new RealVfsFile(*this, std::move(reference), path, perms));
|
return std::shared_ptr<RealVfsFile>(new RealVfsFile(*this, std::move(reference), path, perms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ class IOFile;
|
|||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
struct FileReference : public Common::IntrusiveListBaseNode<FileReference> {
|
struct FileReference : public Common::IntrusiveListBaseNode<FileReference> {
|
||||||
FileReference(std::shared_ptr<Common::FS::IOFile>&& f) : file(f) {}
|
std::shared_ptr<Common::FS::IOFile> file{};
|
||||||
std::shared_ptr<Common::FS::IOFile> file;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RealVfsFile;
|
class RealVfsFile;
|
||||||
|
Loading…
Reference in New Issue
Block a user