Put the human_size() function in util.c

This commit is contained in:
Scott Baker
2021-06-10 12:53:07 -04:00
committed by W. Felix Handte
parent 26fab1d963
commit b70175e5ec
3 changed files with 23 additions and 20 deletions
-20
View File
@@ -1527,26 +1527,6 @@ FIO_compressZstdFrame(FIO_ctx_t* const fCtx,
return compressedfilesize;
}
char* human_size(long size, char* str) {
if (size > 1125899906842624L) {
snprintf(str, 7, "%.1fP", (float)size / 1125899906842624L);
} else if (size > 1099511627776L) {
snprintf(str, 7, "%.1fT", (float)size / 1099511627776L);
} else if (size > 1073741824L) {
snprintf(str, 7, "%.1fG", (float)size / 1073741824L);
} else if (size > 1048576L) {
snprintf(str, 7, "%.1fM", (float)size / 1048576L);
} else if (size > 1024) {
snprintf(str, 7, "%.1fK", (float)size / 1024);
} else if (size >= 0) {
snprintf(str, 7, "%dB", size);
} else {
str[0] = '\0';
}
return str;
}
/*! FIO_compressFilename_internal() :
* same as FIO_compressFilename_extRess(), with `ress.desFile` already opened.
* @return : 0 : compression completed correctly,