diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/idevicebackup2.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index fbe02f8..5ac214e 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -968,7 +968,8 @@ static void mb2_handle_make_directory(plist_t message, const char *backup_dir) | |||
| 968 | static void mb2_copy_file_by_path(const gchar *src, const gchar *dst) | 968 | static void mb2_copy_file_by_path(const gchar *src, const gchar *dst) |
| 969 | { | 969 | { |
| 970 | FILE *from, *to; | 970 | FILE *from, *to; |
| 971 | char ch; | 971 | char buf[BUFSIZ]; |
| 972 | size_t length; | ||
| 972 | 973 | ||
| 973 | /* open source file */ | 974 | /* open source file */ |
| 974 | if ((from = fopen(src, "rb")) == NULL) { | 975 | if ((from = fopen(src, "rb")) == NULL) { |
| @@ -983,19 +984,8 @@ static void mb2_copy_file_by_path(const gchar *src, const gchar *dst) | |||
| 983 | } | 984 | } |
| 984 | 985 | ||
| 985 | /* copy the file */ | 986 | /* copy the file */ |
| 986 | while(!feof(from)) { | 987 | while ((length = fread(buf, 1, BUFSIZ, from)) != 0) { |
| 987 | ch = fgetc(from); | 988 | fwrite(buf, 1, length, to); |
| 988 | if(ferror(from)) { | ||
| 989 | printf("Error reading source file.\n"); | ||
| 990 | break; | ||
| 991 | } | ||
| 992 | if(!feof(from)) | ||
| 993 | fputc(ch, to); | ||
| 994 | |||
| 995 | if(ferror(to)) { | ||
| 996 | printf("Error writing destination file.\n"); | ||
| 997 | break; | ||
| 998 | } | ||
| 999 | } | 989 | } |
| 1000 | 990 | ||
| 1001 | if(fclose(from) == EOF) { | 991 | if(fclose(from) == EOF) { |
