summaryrefslogtreecommitdiff
path: root/unpack/list_files.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-10 21:44:14 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-10 21:52:09 +0100
commit13a0c1b05a4b175f13decf3b15567dc71ea043ac (patch)
treee7d551fd43f69d828c58eb2b9e6d74254bafff10 /unpack/list_files.c
parent060970feee2beea37e837e0a2d557e878e5f8290 (diff)
Cleanup statistics print out
- Give a rounded input/output byte count. - Seperate groups by new lines. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack/list_files.c')
-rw-r--r--unpack/list_files.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/unpack/list_files.c b/unpack/list_files.c
index c08c2dd..238ffec 100644
--- a/unpack/list_files.c
+++ b/unpack/list_files.c
@@ -64,40 +64,23 @@ static int count_int_chars(unsigned int i)
return count;
}
-static void print_size(sqfs_u64 size, char *buffer)
-{
- static const char *suffices = "kMGTPEZY";
- int suffix = -1;
-
- while (size > 1024) {
- ++suffix;
- size /= 1024;
- }
-
- if (suffix >= 0) {
- sprintf(buffer, "%u%c", (unsigned int)size, suffices[suffix]);
- } else {
- sprintf(buffer, "%u", (unsigned int)size);
- }
-}
-
static void print_node_size(const sqfs_tree_node_t *n, char *buffer)
{
switch (n->inode->base.mode & S_IFMT) {
case S_IFLNK:
- print_size(strlen((const char *)n->inode->extra), buffer);
+ print_size(strlen((const char *)n->inode->extra), buffer, true);
break;
case S_IFREG: {
sqfs_u64 size;
sqfs_inode_get_file_size(n->inode, &size);
- print_size(size, buffer);
+ print_size(size, buffer, true);
break;
}
case S_IFDIR:
if (n->inode->base.type == SQFS_INODE_EXT_DIR) {
- print_size(n->inode->data.dir_ext.size, buffer);
+ print_size(n->inode->data.dir_ext.size, buffer, true);
} else {
- print_size(n->inode->data.dir.size, buffer);
+ print_size(n->inode->data.dir.size, buffer, true);
}
break;
case S_IFBLK: