diff --git a/Source/Core/Core/IOS/FS/FileSystem.h b/Source/Core/Core/IOS/FS/FileSystem.h index f02d2eb350..c0f59c2137 100644 --- a/Source/Core/Core/IOS/FS/FileSystem.h +++ b/Source/Core/Core/IOS/FS/FileSystem.h @@ -151,6 +151,14 @@ struct DirectoryStats u32 used_inodes; }; +// Not a real Wii data struct, but useful for calculating how full the user's NAND is even if it's +// way larger than it should be. +struct ExtendedDirectoryStats +{ + u64 used_clusters; + u64 used_inodes; +}; + struct FileStatus { u32 offset; @@ -279,6 +287,9 @@ public: /// Get usage information about a directory (used cluster and inode counts). virtual Result GetDirectoryStats(const std::string& path) = 0; + /// Like GetDirectoryStats() but not limited to the actual 512 MB NAND limit. + virtual Result GetExtendedDirectoryStats(const std::string& path) = 0; + virtual void SetNandRedirects(std::vector nand_redirects) = 0; }; diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index 8c832b2934..a916ffba81 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -803,11 +803,24 @@ Result HostFileSystem::GetNandStats() } Result HostFileSystem::GetDirectoryStats(const std::string& wii_path) +{ + const auto result = GetExtendedDirectoryStats(wii_path); + if (!result) + return result.Error(); + + DirectoryStats stats{}; + stats.used_inodes = static_cast(std::min(result->used_inodes, TOTAL_INODES)); + stats.used_clusters = static_cast(std::min(result->used_clusters, USABLE_CLUSTERS)); + return stats; +} + +Result +HostFileSystem::GetExtendedDirectoryStats(const std::string& wii_path) { if (!IsValidPath(wii_path)) return ResultCode::Invalid; - DirectoryStats stats{}; + ExtendedDirectoryStats stats{}; std::string path(BuildFilename(wii_path).host_path); File::FileInfo info(path); if (!info.Exists()) @@ -820,10 +833,8 @@ Result HostFileSystem::GetDirectoryStats(const std::string& wii_ FixupDirectoryEntries(&parent_dir, wii_path == "/"); // add one for the folder itself - stats.used_inodes = static_cast(std::min(1 + parent_dir.size, TOTAL_INODES)); - - const u64 clusters = ComputeUsedClusters(parent_dir); - stats.used_clusters = static_cast(std::min(clusters, USABLE_CLUSTERS)); + stats.used_inodes = 1 + parent_dir.size; + stats.used_clusters = ComputeUsedClusters(parent_dir); } else { diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.h b/Source/Core/Core/IOS/FS/HostBackend/FS.h index 1248c06736..3c68a59495 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.h +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.h @@ -55,6 +55,7 @@ public: Result GetNandStats() override; Result GetDirectoryStats(const std::string& path) override; + Result GetExtendedDirectoryStats(const std::string& path) override; void SetNandRedirects(std::vector nand_redirects) override;