From eef885a4d14b5fc63b7f0ef6e846b17c7228808c Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 22 Nov 2012 02:44:09 +0100 Subject: idevicebackup2: fix building on win32 --- tools/idevicebackup2.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tools/idevicebackup2.c') diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index d2ec792..2405c87 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -47,7 +46,10 @@ #define LOCK_WAIT 200000 #ifdef WIN32 +#include #define sleep(x) Sleep(x*1000) +#else +#include #endif #define CODE_SUCCESS 0x00 @@ -1574,13 +1576,20 @@ checkpoint: file_count += mb2_handle_receive_files(message, backup_directory); } else if (!strcmp(dlmsg, "DLMessageGetFreeDiskSpace")) { /* device wants to know how much disk space is available on the computer */ + uint64_t freespace = 0; + int res = -1; +#ifdef WIN32 + if (GetDiskFreeSpaceEx(backup_directory, (PULARGE_INTEGER)&freespace, NULL, NULL)) { + res = 0; + } +#else struct statvfs fs; memset(&fs, '\0', sizeof(fs)); - int res = statvfs(backup_directory, &fs); - uint64_t freespace = 0; + res = statvfs(backup_directory, &fs); if (res == 0) { freespace = fs.f_bavail * fs.f_bsize; } +#endif mobilebackup2_send_status_response(mobilebackup2, res, NULL, plist_new_uint(freespace)); } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) { /* list directory contents */ -- cgit v1.1-32-gdbae