From 7c45afecb2a157088591a94f8c008d74419243d1 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 30 Jul 2015 15:06:23 +0200 Subject: Filesystem: Use file info in arguments instead of path Some callers already have the file info, making the relatively slow FindFileInfo calls unnecessary. Callers that didn't have the file info will now need to call FindFileInfo on their own. --- Source/Core/DiscIO/VolumeGC.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Source/Core/DiscIO/VolumeGC.cpp') diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index 39bc029ec2..09f073d075 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -177,7 +177,11 @@ void VolumeGC::LoadBannerFile() const if (!file_system) return; - size_t file_size = static_cast(file_system->GetFileSize("opening.bnr")); + const FileInfo* file_info = file_system->FindFileInfo("opening.bnr"); + if (!file_info) + return; + + size_t file_size = static_cast(file_info->GetSize()); constexpr int BNR1_MAGIC = 0x31524e42; constexpr int BNR2_MAGIC = 0x32524e42; if (file_size != BNR1_SIZE && file_size != BNR2_SIZE) @@ -186,7 +190,11 @@ void VolumeGC::LoadBannerFile() const return; } - file_system->ReadFile("opening.bnr", reinterpret_cast(&banner_file), file_size); + if (file_size != file_system->ReadFile(file_info, reinterpret_cast(&banner_file), file_size)) + { + WARN_LOG(DISCIO, "Could not read opening.bnr."); + return; + } bool is_bnr1; if (banner_file.id == BNR1_MAGIC && file_size == BNR1_SIZE) -- cgit v1.2.3 From 87916fe09979eea276438deef83ba85fcace91e0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 8 Aug 2015 19:59:33 +0200 Subject: Filesystem: Replace GetFileList() Instead of expecting callers to know how the size of directory file infos relates to which files are in which directories, filesystems now offer a GetRoot() method, and file infos offer a way to get their children. As a bonus, m_FileInfoVector no longer has to be created and kept around in RAM. Only the file info objects that actually are used are created. --- Source/Core/DiscIO/VolumeGC.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Source/Core/DiscIO/VolumeGC.cpp') diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index 09f073d075..af4178682f 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -177,7 +177,7 @@ void VolumeGC::LoadBannerFile() const if (!file_system) return; - const FileInfo* file_info = file_system->FindFileInfo("opening.bnr"); + std::unique_ptr file_info = file_system->FindFileInfo("opening.bnr"); if (!file_info) return; @@ -190,7 +190,8 @@ void VolumeGC::LoadBannerFile() const return; } - if (file_size != file_system->ReadFile(file_info, reinterpret_cast(&banner_file), file_size)) + if (file_size != + file_system->ReadFile(file_info.get(), reinterpret_cast(&banner_file), file_size)) { WARN_LOG(DISCIO, "Could not read opening.bnr."); return; -- cgit v1.2.3