summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.c
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 /tools/idevicebackup2.c
parent2155eed0770893983561346699008da2d4c5be90 (diff)
downloadlibimobiledevice-38c4beb0d568dd54c70a4fdb6dadf77ee3ec58dc.tar.gz
libimobiledevice-38c4beb0d568dd54c70a4fdb6dadf77ee3ec58dc.tar.bz2
idevicebackup2: WIN32: Use _stati64() instead of stat() so we can handle file sizes > 4GB
Diffstat (limited to 'tools/idevicebackup2.c')
-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 @@
#include <termios.h>
#include <sys/statvfs.h>
#endif
+#include <sys/stat.h>
#define CODE_SUCCESS 0x00
#define CODE_ERROR_LOCAL 0x06
@@ -627,15 +628,24 @@ static int mb2_handle_send_file(mobilebackup2_client_t mobilebackup2, const char
uint32_t bytes = 0;
char *localfile = build_path(backup_dir, path, NULL);
char buf[32768];
+#ifdef WIN32
+ struct _stati64 fst;
+#else
struct stat fst;
+#endif
FILE *f = NULL;
uint32_t slen = 0;
int errcode = -1;
int result = -1;
uint32_t length;
+#ifdef WIN32
+ uint64_t total;
+ uint64_t sent;
+#else
off_t total;
off_t sent;
+#endif
mobilebackup2_error_t err;
@@ -660,7 +670,12 @@ static int mb2_handle_send_file(mobilebackup2_client_t mobilebackup2, const char
goto leave_proto_err;
}
- if (stat(localfile, &fst) < 0) {
+#ifdef WIN32
+ if (_stati64(localfile, &fst) < 0)
+#else
+ if (stat(localfile, &fst) < 0)
+#endif
+ {
if (errno != ENOENT)
printf("%s: stat failed on '%s': %d\n", __func__, localfile, errno);
errcode = errno;
@@ -687,7 +702,7 @@ static int mb2_handle_send_file(mobilebackup2_client_t mobilebackup2, const char
sent = 0;
do {
- length = ((total-sent) < (off_t)sizeof(buf)) ? (uint32_t)total-sent : (uint32_t)sizeof(buf);
+ length = ((total-sent) < sizeof(buf)) ? (uint32_t)total-sent : (uint32_t)sizeof(buf);
/* send data size (file size + 1) */
nlen = htobe32(length+1);
memcpy(buf, &nlen, sizeof(nlen));