mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-16 07:10:40 +00:00
File.cpp: add rounding_alignment argument to get_dir_size to allow GetSizeKB functions to report size more accurately
This commit is contained in:
parent
9dc06cef7f
commit
08c12f4c00
@ -1,4 +1,4 @@
|
||||
#include "File.h"
|
||||
#include "File.h"
|
||||
#include "mutex.h"
|
||||
#include "StrFmt.h"
|
||||
#include "BEType.h"
|
||||
@ -1580,7 +1580,7 @@ bool fs::remove_all(const std::string& path, bool remove_root)
|
||||
return true;
|
||||
}
|
||||
|
||||
u64 fs::get_dir_size(const std::string& path)
|
||||
u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment)
|
||||
{
|
||||
u64 result = 0;
|
||||
|
||||
@ -1593,12 +1593,12 @@ u64 fs::get_dir_size(const std::string& path)
|
||||
|
||||
if (entry.is_directory == false)
|
||||
{
|
||||
result += entry.size;
|
||||
result += ::align(entry.size, rounding_alignment);
|
||||
}
|
||||
|
||||
if (entry.is_directory == true)
|
||||
{
|
||||
result += get_dir_size(path + '/' + entry.name);
|
||||
result += get_dir_size(path + '/' + entry.name, rounding_alignment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "bit_set.h"
|
||||
@ -506,7 +506,7 @@ namespace fs
|
||||
bool remove_all(const std::string& path, bool remove_root = true);
|
||||
|
||||
// Get size of all files recursively
|
||||
u64 get_dir_size(const std::string& path);
|
||||
u64 get_dir_size(const std::string& path, u64 rounding_alignment = 1);
|
||||
|
||||
enum class error : uint
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ error_code cellHddGameGetSizeKB(vm::ptr<u32> size)
|
||||
return CELL_HDDGAME_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*size = ::narrow<u32>(fs::get_dir_size(local_dir) / 1024);
|
||||
*size = ::narrow<u32>(fs::get_dir_size(local_dir, 1024) / 1024);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -273,7 +273,7 @@ error_code cellGameDataGetSizeKB(vm::ptr<u32> size)
|
||||
return CELL_GAMEDATA_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*size = ::narrow<u32>(fs::get_dir_size(local_dir) / 1024);
|
||||
*size = ::narrow<u32>(fs::get_dir_size(local_dir, 1024) / 1024);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -849,7 +849,7 @@ error_code cellGameGetSizeKB(vm::ptr<s32> size)
|
||||
}
|
||||
}
|
||||
|
||||
*size = ::narrow<u32>(fs::get_dir_size(local_dir) / 1024);
|
||||
*size = ::narrow<u32>(fs::get_dir_size(local_dir, 1024) / 1024);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user