summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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 @@
30#include <libgen.h> 30#include <libgen.h>
31#include <ctype.h> 31#include <ctype.h>
32#include <time.h> 32#include <time.h>
33#include <sys/statvfs.h>
34 33
35#include <libimobiledevice/libimobiledevice.h> 34#include <libimobiledevice/libimobiledevice.h>
36#include <libimobiledevice/lockdown.h> 35#include <libimobiledevice/lockdown.h>
@@ -47,7 +46,10 @@
47#define LOCK_WAIT 200000 46#define LOCK_WAIT 200000
48 47
49#ifdef WIN32 48#ifdef WIN32
49#include <windows.h>
50#define sleep(x) Sleep(x*1000) 50#define sleep(x) Sleep(x*1000)
51#else
52#include <sys/statvfs.h>
51#endif 53#endif
52 54
53#define CODE_SUCCESS 0x00 55#define CODE_SUCCESS 0x00
@@ -1574,13 +1576,20 @@ checkpoint:
1574 file_count += mb2_handle_receive_files(message, backup_directory); 1576 file_count += mb2_handle_receive_files(message, backup_directory);
1575 } else if (!strcmp(dlmsg, "DLMessageGetFreeDiskSpace")) { 1577 } else if (!strcmp(dlmsg, "DLMessageGetFreeDiskSpace")) {
1576 /* device wants to know how much disk space is available on the computer */ 1578 /* device wants to know how much disk space is available on the computer */
1579 uint64_t freespace = 0;
1580 int res = -1;
1581#ifdef WIN32
1582 if (GetDiskFreeSpaceEx(backup_directory, (PULARGE_INTEGER)&freespace, NULL, NULL)) {
1583 res = 0;
1584 }
1585#else
1577 struct statvfs fs; 1586 struct statvfs fs;
1578 memset(&fs, '\0', sizeof(fs)); 1587 memset(&fs, '\0', sizeof(fs));
1579 int res = statvfs(backup_directory, &fs); 1588 res = statvfs(backup_directory, &fs);
1580 uint64_t freespace = 0;
1581 if (res == 0) { 1589 if (res == 0) {
1582 freespace = fs.f_bavail * fs.f_bsize; 1590 freespace = fs.f_bavail * fs.f_bsize;
1583 } 1591 }
1592#endif
1584 mobilebackup2_send_status_response(mobilebackup2, res, NULL, plist_new_uint(freespace)); 1593 mobilebackup2_send_status_response(mobilebackup2, res, NULL, plist_new_uint(freespace));
1585 } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) { 1594 } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) {
1586 /* list directory contents */ 1595 /* list directory contents */