From 95bc57cff3f81f98b172d20a20b503a332fa2603 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 20 Jul 2015 21:21:24 +0200 Subject: DiscScrubber: Use FileInfo::IsDirectory instead of bit magic --- Source/Core/DiscIO/DiscScrubber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/DiscIO/DiscScrubber.cpp') diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index fff2db9ab6..6b56d8b607 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -222,7 +222,7 @@ bool DiscScrubber::ParsePartitionData(const Partition& partition, PartitionHeade for (const FileInfo& file : filesystem->GetFileList()) { DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str()); - if ((file.m_NameOffset & 0x1000000) == 0) + if (!file.IsDirectory()) MarkAsUsedE(partition_data_offset, file.m_Offset, file.m_FileSize); } -- cgit v1.2.3 From 5021b4a567fad9a258f2b0fc397912f499e4cb1d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 28 Jul 2015 16:56:25 +0200 Subject: Filesystem: Replace FileInfo struct with interface GC/Wii filesystem internals shouldn't be exposed to other classes. This change isn't especially useful by itself, but it opens up the way for some neat stuff in the following commits. --- Source/Core/DiscIO/DiscScrubber.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Source/Core/DiscIO/DiscScrubber.cpp') diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 6b56d8b607..70f9bed79a 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -16,6 +16,8 @@ #include "Common/Logging/Log.h" #include "DiscIO/DiscScrubber.h" #include "DiscIO/Filesystem.h" +// TODO: eww +#include "DiscIO/FileSystemGCWii.h" #include "DiscIO/Volume.h" namespace DiscIO @@ -219,11 +221,11 @@ bool DiscScrubber::ParsePartitionData(const Partition& partition, PartitionHeade MarkAsUsedE(partition_data_offset, header->fst_offset, header->fst_size); // Go through the filesystem and mark entries as used - for (const FileInfo& file : filesystem->GetFileList()) + for (const FileInfoGCWii& file : filesystem->GetFileList()) { DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str()); if (!file.IsDirectory()) - MarkAsUsedE(partition_data_offset, file.m_Offset, file.m_FileSize); + MarkAsUsedE(partition_data_offset, file.GetOffset(), file.GetSize()); } return true; -- cgit v1.2.3 From 07d3a39aeb06204e13cfdf1d5f7dbe4f3aa66f89 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 29 Jul 2015 16:42:29 +0200 Subject: Filesystem: Replace file info's full path with name Some callers (i.e. ISOProperties) don't want the full path, so giving them it is unnecessary. Those that do want it can use GetPathFromFSTOffset. Not storing full paths everywhere also saves a small bit of RAM and is necessary for a later commit. The code isn't especially pretty right now (callers need to use FST offsets...) but it'll become better later. --- Source/Core/DiscIO/DiscScrubber.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Source/Core/DiscIO/DiscScrubber.cpp') diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 70f9bed79a..71d1fa16bc 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -221,9 +221,12 @@ bool DiscScrubber::ParsePartitionData(const Partition& partition, PartitionHeade MarkAsUsedE(partition_data_offset, header->fst_offset, header->fst_size); // Go through the filesystem and mark entries as used - for (const FileInfoGCWii& file : filesystem->GetFileList()) + auto& file_list = filesystem->GetFileList(); + for (size_t i = 0; i < file_list.size(); ++i) { - DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str()); + const std::string path = filesystem->GetPathFromFSTOffset(i); + DEBUG_LOG(DISCIO, "%s", path.empty() ? "/" : path.c_str()); + auto& file = file_list[i]; if (!file.IsDirectory()) MarkAsUsedE(partition_data_offset, file.GetOffset(), file.GetSize()); } -- 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/DiscScrubber.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'Source/Core/DiscIO/DiscScrubber.cpp') diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 71d1fa16bc..009081cbb6 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -16,8 +16,6 @@ #include "Common/Logging/Log.h" #include "DiscIO/DiscScrubber.h" #include "DiscIO/Filesystem.h" -// TODO: eww -#include "DiscIO/FileSystemGCWii.h" #include "DiscIO/Volume.h" namespace DiscIO @@ -221,17 +219,21 @@ bool DiscScrubber::ParsePartitionData(const Partition& partition, PartitionHeade MarkAsUsedE(partition_data_offset, header->fst_offset, header->fst_size); // Go through the filesystem and mark entries as used - auto& file_list = filesystem->GetFileList(); - for (size_t i = 0; i < file_list.size(); ++i) - { - const std::string path = filesystem->GetPathFromFSTOffset(i); - DEBUG_LOG(DISCIO, "%s", path.empty() ? "/" : path.c_str()); - auto& file = file_list[i]; - if (!file.IsDirectory()) - MarkAsUsedE(partition_data_offset, file.GetOffset(), file.GetSize()); - } + ParseFileSystemData(partition_data_offset, filesystem->GetRoot()); return true; } +void DiscScrubber::ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory) +{ + for (const DiscIO::FileInfo& file_info : directory) + { + DEBUG_LOG(DISCIO, "Scrubbing %s", file_info.GetPath().c_str()); + if (file_info.IsDirectory()) + ParseFileSystemData(partition_data_offset, file_info); + else + MarkAsUsedE(partition_data_offset, file_info.GetOffset(), file_info.GetSize()); + } +} + } // namespace DiscIO -- cgit v1.2.3