diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-07-14 04:16:56 +0200 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-07-14 04:48:23 +0200 |
| commit | efae5827f211c41778e8d0c66623655488fdd1fd (patch) | |
| tree | e0172651c79752f648f31f9db65c81ccb1d94073 /Source | |
| parent | 0d9e027a0b54ff8c4a3be2ce3b743eb98b2d35bc (diff) | |
IOS/FS: Implement GetExtendedDirectoryStats().
Behaves like GetDirectoryStats() but doesn't clamp to the Wii limits, so we can tell the user exactly how overfull their NAND is.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/IOS/FS/FileSystem.h | 11 | ||||
| -rw-r--r-- | Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/Core/IOS/FS/HostBackend/FS.h | 1 |
3 files changed, 28 insertions, 5 deletions
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<DirectoryStats> GetDirectoryStats(const std::string& path) = 0; + /// Like GetDirectoryStats() but not limited to the actual 512 MB NAND limit. + virtual Result<ExtendedDirectoryStats> GetExtendedDirectoryStats(const std::string& path) = 0; + virtual void SetNandRedirects(std::vector<NandRedirect> 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 @@ -804,10 +804,23 @@ Result<NandStats> HostFileSystem::GetNandStats() Result<DirectoryStats> 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<u32>(std::min<u64>(result->used_inodes, TOTAL_INODES)); + stats.used_clusters = static_cast<u32>(std::min<u64>(result->used_clusters, USABLE_CLUSTERS)); + return stats; +} + +Result<ExtendedDirectoryStats> +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<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_ FixupDirectoryEntries(&parent_dir, wii_path == "/"); // add one for the folder itself - stats.used_inodes = static_cast<u32>(std::min<u64>(1 + parent_dir.size, TOTAL_INODES)); - - const u64 clusters = ComputeUsedClusters(parent_dir); - stats.used_clusters = static_cast<u32>(std::min<u64>(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<NandStats> GetNandStats() override; Result<DirectoryStats> GetDirectoryStats(const std::string& path) override; + Result<ExtendedDirectoryStats> GetExtendedDirectoryStats(const std::string& path) override; void SetNandRedirects(std::vector<NandRedirect> nand_redirects) override; |
