IOS/FS: GetDirectoryStats() should return an error if the given path is not a directory.

This commit is contained in:
Admiral H. Curtiss 2023-03-31 19:50:00 +02:00
parent 4c80c992eb
commit 69d6be09f7
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
1 changed files with 7 additions and 2 deletions

View File

@ -771,7 +771,12 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
DirectoryStats stats{};
std::string path(BuildFilename(wii_path).host_path);
if (File::IsDirectory(path))
File::FileInfo info(path);
if (!info.Exists())
{
return ResultCode::NotFound;
}
if (info.IsDirectory())
{
File::FSTEntry parent_dir = File::ScanDirectoryTree(path, true);
// add one for the folder itself
@ -783,7 +788,7 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
}
else
{
WARN_LOG_FMT(IOS_FS, "fsBlock failed, cannot find directory: {}", path);
return ResultCode::Invalid;
}
return stats;
}