Преглед на файлове

vfs_real: lazily open files

Liam преди 3 години
родител
ревизия
0e7eaaba5a
променени са 2 файла, в които са добавени 3 реда и са изтрити 11 реда
  1. 2 9
      src/core/file_sys/vfs_real.cpp
  2. 1 2
      src/core/file_sys/vfs_real.h

+ 2 - 9
src/core/file_sys/vfs_real.cpp

@@ -75,16 +75,9 @@ VfsEntryType RealVfsFilesystem::GetEntryType(std::string_view path_) const {
 VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
     const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
 
-    this->EvictSingleReference();
-
-    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));
+    auto reference = std::make_unique<FileReference>();
     this->InsertReferenceIntoList(*reference);
+
     return std::shared_ptr<RealVfsFile>(new RealVfsFile(*this, std::move(reference), path, perms));
 }
 

+ 1 - 2
src/core/file_sys/vfs_real.h

@@ -15,8 +15,7 @@ class IOFile;
 namespace FileSys {
 
 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;