summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-03-24 13:29:00 +0100
committerGravatar Nikias Bassen2014-03-24 13:29:00 +0100
commit38c4beb0d568dd54c70a4fdb6dadf77ee3ec58dc (patch)
tree453305815b6f3547fb704ecb042055c144a2003a
parent2155eed0770893983561346699008da2d4c5be90 (diff)
downloadlibimobiledevice-38c4beb0d568dd54c70a4fdb6dadf77ee3ec58dc.tar.gz
libimobiledevice-38c4beb0d568dd54c70a4fdb6dadf77ee3ec58dc.tar.bz2
idevicebackup2: WIN32: Use _stati64() instead of stat() so we can handle file sizes > 4GB
-rw-r--r--tools/idevicebackup2.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index a9bf071..b5bbd57 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -50,6 +50,7 @@
50#include <termios.h> 50#include <termios.h>
51#include <sys/statvfs.h> 51#include <sys/statvfs.h>
52#endif 52#endif
53#include <sys/stat.h>
53 54
54#define CODE_SUCCESS 0x00 55#define CODE_SUCCESS 0x00
55#define CODE_ERROR_LOCAL 0x06 56#define CODE_ERROR_LOCAL 0x06
@@ -627,15 +628,24 @@ static int mb2_handle_send_file(mobilebackup2_client_t mobilebackup2, const char
627 uint32_t bytes = 0; 628 uint32_t bytes = 0;
628 char *localfile = build_path(backup_dir, path, NULL); 629 char *localfile = build_path(backup_dir, path, NULL);
629 char buf[32768]; 630 char buf[32768];
631#ifdef WIN32
632 struct _stati64 fst;
633#else
630 struct stat fst; 634 struct stat fst;
635#endif
631 636
632 FILE *f = NULL; 637 FILE *f = NULL;
633 uint32_t slen = 0; 638 uint32_t slen = 0;
634 int errcode = -1; 639 int errcode = -1;
635 int result = -1; 640 int result = -1;
636 uint32_t length; 641 uint32_t length;
642#ifdef WIN32
643 uint64_t total;
644 uint64_t sent;
645#else
637 off_t total; 646 off_t total;
638 off_t sent; 647 off_t sent;
648#endif
639 649
640 mobilebackup2_error_t err; 650 mobilebackup2_error_t err;
641 651
@@ -660,7 +670,12 @@ static int mb2_handle_send_file(mobilebackup2_client_t mobilebackup2, const char
660 goto leave_proto_err; 670 goto leave_proto_err;
661 } 671 }
662 672
663 if (stat(localfile, &fst) < 0) { 673#ifdef WIN32
674 if (_stati64(localfile, &fst) < 0)
675#else
676 if (stat(localfile, &fst) < 0)
677#endif
678 {
664 if (errno != ENOENT) 679 if (errno != ENOENT)
665 printf("%s: stat failed on '%s': %d\n", __func__, localfile, errno); 680 printf("%s: stat failed on '%s': %d\n", __func__, localfile, errno);
666 errcode = errno; 681 errcode = errno;
@@ -687,7 +702,7 @@ static int mb2_handle_send_file(mobilebackup2_client_t mobilebackup2, const char
687 702
688 sent = 0; 703 sent = 0;
689 do { 704 do {
690 length = ((total-sent) < (off_t)sizeof(buf)) ? (uint32_t)total-sent : (uint32_t)sizeof(buf); 705 length = ((total-sent) < sizeof(buf)) ? (uint32_t)total-sent : (uint32_t)sizeof(buf);
691 /* send data size (file size + 1) */ 706 /* send data size (file size + 1) */
692 nlen = htobe32(length+1); 707 nlen = htobe32(length+1);
693 memcpy(buf, &nlen, sizeof(nlen)); 708 memcpy(buf, &nlen, sizeof(nlen));