From 565b869438b16eb074a054e770e71c684dbfb2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Mon, 26 Dec 2011 23:39:43 +0000 Subject: [PATCH] file properties: display correctly file/folder sizes > 2GB Use unsigned type for file sizes (some directory/file structures should be changed too) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31449 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/properties.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index c38c6d5ec5..de80e2ad70 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -40,7 +40,7 @@ char str_duration[32]; int num_properties; static const char human_size_prefix[4] = { '\0', 'K', 'M', 'G' }; -static unsigned human_size_log(long long size) +static unsigned human_size_log(unsigned long long size) { const size_t n = sizeof(human_size_prefix)/sizeof(human_size_prefix[0]); @@ -76,9 +76,9 @@ static bool file_properties(char* selected_file) rb->snprintf(str_dirname, sizeof str_dirname, "Path: %s", tstr); rb->snprintf(str_filename, sizeof str_filename, "Name: %s", selected_file+dirlen); - log = human_size_log(info.size); - rb->snprintf(str_size, sizeof str_size, "Size: %ld %cB", - info.size >> (log*10), human_size_prefix[log]); + log = human_size_log((unsigned long)info.size); + rb->snprintf(str_size, sizeof str_size, "Size: %lu %cB", + ((unsigned long)info.size) >> (log*10), human_size_prefix[log]); rb->snprintf(str_date, sizeof str_date, "Date: %04d/%02d/%02d", ((info.wrtdate >> 9 ) & 0x7F) + 1980, /* year */ ((info.wrtdate >> 5 ) & 0x0F), /* month */ @@ -138,7 +138,7 @@ typedef struct { int len; unsigned int dc; unsigned int fc; - long long bc; + unsigned long long bc; } DPS; static bool _dir_properties(DPS* dps) @@ -184,7 +184,7 @@ static bool _dir_properties(DPS* dps) rb->lcd_putsf(0,3,"Directories: %d", dps->dc); rb->lcd_putsf(0,4,"Files: %d", dps->fc); log = human_size_log(dps->bc); - rb->lcd_putsf(0,5,"Size: %ld %cB", (long) (dps->bc >> (10*log)), + rb->lcd_putsf(0,5,"Size: %lu %cB", (unsigned long)(dps->bc >> (10*log)), human_size_prefix[log]); rb->lcd_update(); }