This adds a second parameter to size_to_human_string() to return a
string with a different format based on the following flags: SIZE_SUFFIX_1LETTER = "1K" SIZE_SUFFIX_3LETTER = "1KiB", SIZE_SUFFIX_SPACE = "1 KiB" or "1 K" [kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format, - fix suffix[] buffer size - add 3 letter version to the test] Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
2b85ab880d
commit
5d2a98490e
5 changed files with 65 additions and 39 deletions
|
@ -27,6 +27,15 @@ static inline void xstrncpy(char *dest, const char *src, size_t n)
|
|||
}
|
||||
|
||||
extern void strmode(mode_t mode, char *str);
|
||||
extern char *size_to_human_string(uint64_t bytes);
|
||||
|
||||
/* Options for size_to_human_string() */
|
||||
enum
|
||||
{
|
||||
SIZE_SUFFIX_1LETTER = 0,
|
||||
SIZE_SUFFIX_3LETTER = 1,
|
||||
SIZE_SUFFIX_SPACE = 2
|
||||
};
|
||||
|
||||
extern char *size_to_human_string(int options, uint64_t bytes);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue