-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Make the CLI summary data use a human readable format instead of raw bytes #2696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
49dd77b
e93fdd3
4792532
9da459f
2342122
e4e7358
dcfaf26
b63b497
dbb3cd2
91840eb
d67d965
fdcfc18
a1d128a
10748cb
23b6c67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,27 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, | |
| * Functions | ||
| ***************************************/ | ||
|
|
||
| char* humanSize(unsigned long long size, char* str) { | ||
| if (size > 1125899906842624L) { | ||
| snprintf(str, 7, "%.1fP", (float)size / 1125899906842624L); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You could consider rewriting this to not require an intermediate buffer if you just output a rescaled float value and a (static) suffix string that are then passed to the A worst case alternative is that you just wrap this in an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see references to C is not my forte, so I may need some guidance on this one.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As C has evolved, they've introduced new functions into the same header. C90 has |
||
| } 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 <= 1024) { | ||
| snprintf(str, 7, "%lluB", size); | ||
scottchiefbaker marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| str[0] = '\0'; | ||
scottchiefbaker marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return str; | ||
| } | ||
|
|
||
|
|
||
| int UTIL_stat(const char* filename, stat_t* statbuf) | ||
| { | ||
| #if defined(_MSC_VER) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,8 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, const | |
| #define STRDUP(s) strdup(s) | ||
| #endif | ||
|
|
||
| char* humanSize(unsigned long long size, char* str); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to a more descriptive name? Maybe add a little comment here describing what it does?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open to naming suggestions. I will definitely add a description though, that's easy.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
|
|
||
| /** | ||
| * Calls platform's equivalent of stat() on filename and writes info to statbuf. | ||
| * Returns success (1) or failure (0). | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.