mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
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.
This commit is contained in:
parent
0d9e027a0b
commit
efae5827f2
@ -151,6 +151,14 @@ struct DirectoryStats
|
|||||||
u32 used_inodes;
|
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
|
struct FileStatus
|
||||||
{
|
{
|
||||||
u32 offset;
|
u32 offset;
|
||||||
@ -279,6 +287,9 @@ public:
|
|||||||
/// Get usage information about a directory (used cluster and inode counts).
|
/// Get usage information about a directory (used cluster and inode counts).
|
||||||
virtual Result<DirectoryStats> GetDirectoryStats(const std::string& path) = 0;
|
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;
|
virtual void SetNandRedirects(std::vector<NandRedirect> nand_redirects) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -803,11 +803,24 @@ Result<NandStats> HostFileSystem::GetNandStats()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_path)
|
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))
|
if (!IsValidPath(wii_path))
|
||||||
return ResultCode::Invalid;
|
return ResultCode::Invalid;
|
||||||
|
|
||||||
DirectoryStats stats{};
|
ExtendedDirectoryStats stats{};
|
||||||
std::string path(BuildFilename(wii_path).host_path);
|
std::string path(BuildFilename(wii_path).host_path);
|
||||||
File::FileInfo info(path);
|
File::FileInfo info(path);
|
||||||
if (!info.Exists())
|
if (!info.Exists())
|
||||||
@ -820,10 +833,8 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
|
|||||||
FixupDirectoryEntries(&parent_dir, wii_path == "/");
|
FixupDirectoryEntries(&parent_dir, wii_path == "/");
|
||||||
|
|
||||||
// add one for the folder itself
|
// add one for the folder itself
|
||||||
stats.used_inodes = static_cast<u32>(std::min<u64>(1 + parent_dir.size, TOTAL_INODES));
|
stats.used_inodes = 1 + parent_dir.size;
|
||||||
|
stats.used_clusters = ComputeUsedClusters(parent_dir);
|
||||||
const u64 clusters = ComputeUsedClusters(parent_dir);
|
|
||||||
stats.used_clusters = static_cast<u32>(std::min<u64>(clusters, USABLE_CLUSTERS));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
|
|
||||||
Result<NandStats> GetNandStats() override;
|
Result<NandStats> GetNandStats() override;
|
||||||
Result<DirectoryStats> GetDirectoryStats(const std::string& path) 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;
|
void SetNandRedirects(std::vector<NandRedirect> nand_redirects) override;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user