diff options
author | Martin Szulecki | 2014-10-22 21:28:04 +0200 |
---|---|---|
committer | Martin Szulecki | 2014-10-22 22:21:06 +0200 |
commit | 2f32ff99f90689b364b86d4c12f3a1b8b318991e (patch) | |
tree | 16df4749e950bce8fd57a88997af342f6e81bddc /tools/idevicebackup.c | |
parent | 57538472cb86d6b376f933e9e416eb769f7c00b7 (diff) | |
download | libimobiledevice-2f32ff99f90689b364b86d4c12f3a1b8b318991e.tar.gz libimobiledevice-2f32ff99f90689b364b86d4c12f3a1b8b318991e.tar.bz2 |
common: Move size format helper to utils and use it in idevicebackup tools
Diffstat (limited to 'tools/idevicebackup.c')
-rw-r--r-- | tools/idevicebackup.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 8260de6..195f837 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -224,25 +224,6 @@ static void notify_cb(const char *notification, void *userdata) } } -static char* format_size_for_display(uint64_t size) -{ - char buf[32]; - double sz; - if (size >= 1000000000LL) { - sz = ((double)size / 1000000000.0f); - sprintf(buf, "%0.1f GB", sz); - } else if (size >= 1000000LL) { - sz = ((double)size / 1000000.0f); - sprintf(buf, "%0.1f MB", sz); - } else if (size >= 1000LL) { - sz = ((double)size / 1000.0f); - sprintf(buf, "%0.1f kB", sz); - } else { - sprintf(buf, "%d Bytes", (int)size); - } - return strdup(buf); -} - static plist_t mobilebackup_factory_info_plist_new(const char* udid) { /* gather data from lockdown */ @@ -1037,7 +1018,7 @@ int main(int argc, char *argv[]) node = plist_dict_get_item(node_tmp, "BackupTotalSizeKey"); if (node) { plist_get_uint_val(node, &backup_total_size); - format_size = format_size_for_display(backup_total_size); + format_size = string_format_size(backup_total_size); printf("Backup data requires %s on the disk.\n", format_size); free(format_size); } @@ -1067,15 +1048,15 @@ int main(int argc, char *argv[]) plist_get_uint_val(node, &file_size); backup_real_size += file_size; - format_size = format_size_for_display(backup_real_size); + format_size = string_format_size(backup_real_size); printf("(%s", format_size); free(format_size); - format_size = format_size_for_display(backup_total_size); + format_size = string_format_size(backup_total_size); printf("/%s): ", format_size); free(format_size); - format_size = format_size_for_display(file_size); + format_size = string_format_size(file_size); printf("Receiving file %s (%s)... \n", filename_source, format_size); free(format_size); |