summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-11-22 02:44:09 +0100
committerGravatar Nikias Bassen2012-11-22 02:44:09 +0100
commiteef885a4d14b5fc63b7f0ef6e846b17c7228808c (patch)
tree5ab0eef668c833003ff1584ffb9581db39eacae5 /tools/idevicebackup2.c
parent2acd72313826596a86ad08ef8857f510a2555fb5 (diff)
downloadlibimobiledevice-eef885a4d14b5fc63b7f0ef6e846b17c7228808c.tar.gz
libimobiledevice-eef885a4d14b5fc63b7f0ef6e846b17c7228808c.tar.bz2
idevicebackup2: fix building on win32
Diffstat (limited to 'tools/idevicebackup2.c')
-rw-r--r--tools/idevicebackup2.c15
1 files changed, 12 insertions, 3 deletions
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 <libgen.h>
#include <ctype.h>
#include <time.h>
-#include <sys/statvfs.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
@@ -47,7 +46,10 @@
#define LOCK_WAIT 200000
#ifdef WIN32
+#include <windows.h>
#define sleep(x) Sleep(x*1000)
+#else
+#include <sys/statvfs.h>
#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 */