13
#include "help.h"
14
#include "archive.h"
15
#include "object-store.h"
16
+#include "compat/disk.h"
17
18
/*
19
* Remove the deepest subdirectory in the provided path string. Path must not
310
return res;
311
}
312
312
-#ifndef WIN32
313
-#include <sys/statvfs.h>
314
-#endif
315
-
316
-static int get_disk_info(struct strbuf *out)
317
-{
318
-#ifdef WIN32
319
- struct strbuf buf = STRBUF_INIT;
320
- char volume_name[MAX_PATH], fs_name[MAX_PATH];
321
- DWORD serial_number, component_length, flags;
322
- ULARGE_INTEGER avail2caller, total, avail;
323
-
324
- strbuf_realpath(&buf, ".", 1);
325
- if (!GetDiskFreeSpaceExA(buf.buf, &avail2caller, &total, &avail)) {
326
- error(_("could not determine free disk size for '%s'"),
327
- buf.buf);
328
- strbuf_release(&buf);
329
- return -1;
330
- }
331
-
332
- strbuf_setlen(&buf, offset_1st_component(buf.buf));
333
- if (!GetVolumeInformationA(buf.buf, volume_name, sizeof(volume_name),
334
- &serial_number, &component_length, &flags,
335
- fs_name, sizeof(fs_name))) {
336
- error(_("could not get info for '%s'"), buf.buf);
337
- strbuf_release(&buf);
338
- return -1;
339
- }
340
- strbuf_addf(out, "Available space on '%s': ", buf.buf);
341
- strbuf_humanise_bytes(out, avail2caller.QuadPart);
342
- strbuf_addch(out, '\n');
343
- strbuf_release(&buf);
344
-#else
345
- struct strbuf buf = STRBUF_INIT;
346
- struct statvfs stat;
347
-
348
- strbuf_realpath(&buf, ".", 1);
349
- if (statvfs(buf.buf, &stat) < 0) {
350
- error_errno(_("could not determine free disk size for '%s'"),
351
- buf.buf);
352
- strbuf_release(&buf);
353
- return -1;
354
- }
355
-
356
- strbuf_addf(out, "Available space on '%s': ", buf.buf);
357
- strbuf_humanise_bytes(out, (off_t)stat.f_bsize * (off_t)stat.f_bavail);
358
- strbuf_addf(out, " (mount flags 0x%lx)\n", stat.f_flag);
359
- strbuf_release(&buf);
360
-#endif
361
- return 0;
362
-}
363
-
313
/* printf-style interface, expects `<key>=<value>` argument */
314
static int set_config(const char *fmt, ...)
315
{