Merge pull request #853 from akuker/rdmark-issue852

Calculate image sizes for the Product string using MiB/KiB units
This commit is contained in:
Daniel Markstedt 2022-09-29 19:31:42 -07:00 committed by GitHub
commit 71e070b59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -41,13 +41,13 @@ void SCSIHD::FinalizeSetup(const Filepath &path, off_t size)
if (!IsRemovable()) {
uint64_t capacity = GetBlockCount() * GetSectorSizeInBytes();
string unit;
if (capacity >= 1000000) {
capacity /= 1000000;
unit = "MB";
if (capacity >= 1048576) {
capacity /= 1048576;
unit = "MiB";
}
else {
capacity /= 1000;
unit = "KB";
capacity /= 1024;
unit = "KiB";
}
stringstream product;
product << DEFAULT_PRODUCT << " " << capacity << " " << unit;