mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-19 09:25:12 -04:00
[misc] cleanup and refactoring + fix WIM 7z minor issue
* remove hardcoded path from WimExtractFile_7z * move some drive related functions to drive.c * cleanup
This commit is contained in:
parent
8ff8b41273
commit
c8acf1b84a
8 changed files with 209 additions and 202 deletions
19
src/stdio.c
19
src/stdio.c
|
@ -189,6 +189,25 @@ char* GuidToString(const GUID* guid)
|
|||
return guid_string;
|
||||
}
|
||||
|
||||
// Convert a file size to human readable
|
||||
char* SizeToHumanReadable(LARGE_INTEGER size)
|
||||
{
|
||||
int suffix = 0;
|
||||
static char str_size[24];
|
||||
const char* sizes[] = { "", "KB", "MB", "GB", "TB" };
|
||||
double hr_size = (double)size.QuadPart;
|
||||
while ((suffix < ARRAYSIZE(sizes)) && (hr_size >= 1024.0)) {
|
||||
hr_size /= 1024.0;
|
||||
suffix++;
|
||||
}
|
||||
if (suffix == 0) {
|
||||
safe_sprintf(str_size, sizeof(str_size), "%d bytes", (int)hr_size);
|
||||
} else {
|
||||
safe_sprintf(str_size, sizeof(str_size), "%0.1f %s", hr_size, sizes[suffix]);
|
||||
}
|
||||
return str_size;
|
||||
}
|
||||
|
||||
const char* StrError(DWORD error_code)
|
||||
{
|
||||
if ( (!IS_ERROR(error_code)) || (SCODE_CODE(error_code) == ERROR_SUCCESS)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue