mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Put the human_size() function in util.c
This commit is contained in:
committed by
W. Felix Handte
parent
26fab1d963
commit
b70175e5ec
@ -121,6 +121,27 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg,
|
||||
* Functions
|
||||
***************************************/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int UTIL_stat(const char* filename, stat_t* statbuf)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
|
Reference in New Issue
Block a user