diff options
| author | 2010-11-28 18:48:16 +0100 | |
|---|---|---|
| committer | 2011-04-11 19:42:18 +0200 | |
| commit | 016c8d39185824da3d7c5d6fa7f720bf176260cc (patch) | |
| tree | fd9eb1a42328c0bb3d1383ded31013592816b86b /tools | |
| parent | 59da81439f176f950b3cd7d4e3d67af8ab6d8508 (diff) | |
| download | libimobiledevice-016c8d39185824da3d7c5d6fa7f720bf176260cc.tar.gz libimobiledevice-016c8d39185824da3d7c5d6fa7f720bf176260cc.tar.bz2 | |
idevicebackup4: Show current transfer size in progress output, too
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/idevicebackup4.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/idevicebackup4.c b/tools/idevicebackup4.c index fa00713..4e079f1 100644 --- a/tools/idevicebackup4.c +++ b/tools/idevicebackup4.c | |||
| @@ -764,9 +764,11 @@ static void do_post_notification(const char *notification) | |||
| 764 | } | 764 | } |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | static void print_progress(double progress) | 767 | static void print_progress(uint64_t current, uint64_t total) |
| 768 | { | 768 | { |
| 769 | gchar *format_size = NULL; | ||
| 769 | int i = 0; | 770 | int i = 0; |
| 771 | double progress = ((double)current/(double)total)*100; | ||
| 770 | if (progress < 0) | 772 | if (progress < 0) |
| 771 | return; | 773 | return; |
| 772 | 774 | ||
| @@ -782,6 +784,14 @@ static void print_progress(double progress) | |||
| 782 | } | 784 | } |
| 783 | } | 785 | } |
| 784 | printf("] %3.0f%%", progress); | 786 | printf("] %3.0f%%", progress); |
| 787 | |||
| 788 | format_size = g_format_size_for_display(current); | ||
| 789 | printf(" (%s", format_size); | ||
| 790 | g_free(format_size); | ||
| 791 | format_size = g_format_size_for_display(total); | ||
| 792 | printf("/%s)", format_size); | ||
| 793 | g_free(format_size); | ||
| 794 | |||
| 785 | fflush(stdout); | 795 | fflush(stdout); |
| 786 | if (progress == 100) | 796 | if (progress == 100) |
| 787 | printf("\n"); | 797 | printf("\n"); |
| @@ -1001,9 +1011,7 @@ static int handle_receive_files(plist_t message, const char *backup_dir) | |||
| 1001 | plist_get_uint_val(node, &backup_total_size); | 1011 | plist_get_uint_val(node, &backup_total_size); |
| 1002 | } | 1012 | } |
| 1003 | if (backup_total_size > 0) { | 1013 | if (backup_total_size > 0) { |
| 1004 | gchar *format_size = g_format_size_for_display(backup_total_size); | 1014 | printf("Receiving backup data\n"); |
| 1005 | printf("Receiving backup data (%s)\n", format_size); | ||
| 1006 | g_free(format_size); | ||
| 1007 | } | 1015 | } |
| 1008 | 1016 | ||
| 1009 | do { | 1017 | do { |
| @@ -1067,6 +1075,9 @@ static int handle_receive_files(plist_t message, const char *backup_dir) | |||
| 1067 | if (bdone == blocksize) { | 1075 | if (bdone == blocksize) { |
| 1068 | backup_real_size += blocksize; | 1076 | backup_real_size += blocksize; |
| 1069 | } | 1077 | } |
| 1078 | if (backup_total_size > 0) { | ||
| 1079 | print_progress(backup_real_size, backup_total_size); | ||
| 1080 | } | ||
| 1070 | if (quit_flag) | 1081 | if (quit_flag) |
| 1071 | break; | 1082 | break; |
| 1072 | nlen = 0; | 1083 | nlen = 0; |
| @@ -1082,7 +1093,7 @@ static int handle_receive_files(plist_t message, const char *backup_dir) | |||
| 1082 | 1093 | ||
| 1083 | file_count++; | 1094 | file_count++; |
| 1084 | if (backup_total_size > 0) | 1095 | if (backup_total_size > 0) |
| 1085 | print_progress(((double)backup_real_size/(double)backup_total_size)*100); | 1096 | print_progress(backup_real_size, backup_total_size); |
| 1086 | if (nlen == 0) { | 1097 | if (nlen == 0) { |
| 1087 | break; | 1098 | break; |
| 1088 | } | 1099 | } |
