4 #include "git-compat-util.h"
6 static int get_disk_info(struct strbuf
*out
)
8 struct strbuf buf
= STRBUF_INIT
;
11 #ifdef GIT_WINDOWS_NATIVE
12 char volume_name
[MAX_PATH
], fs_name
[MAX_PATH
];
13 DWORD serial_number
, component_length
, flags
;
14 ULARGE_INTEGER avail2caller
, total
, avail
;
16 strbuf_realpath(&buf
, ".", 1);
17 if (!GetDiskFreeSpaceExA(buf
.buf
, &avail2caller
, &total
, &avail
)) {
18 error(_("could not determine free disk size for '%s'"),
24 strbuf_setlen(&buf
, offset_1st_component(buf
.buf
));
25 if (!GetVolumeInformationA(buf
.buf
, volume_name
, sizeof(volume_name
),
26 &serial_number
, &component_length
, &flags
,
27 fs_name
, sizeof(fs_name
))) {
28 error(_("could not get info for '%s'"), buf
.buf
);
32 strbuf_addf(out
, "Available space on '%s': ", buf
.buf
);
33 strbuf_humanise_bytes(out
, avail2caller
.QuadPart
);
34 strbuf_addch(out
, '\n');
38 strbuf_realpath(&buf
, ".", 1);
39 if (statvfs(buf
.buf
, &stat
) < 0) {
40 error_errno(_("could not determine free disk size for '%s'"),
46 strbuf_addf(out
, "Available space on '%s': ", buf
.buf
);
47 strbuf_humanise_bytes(out
, (off_t
)stat
.f_bsize
* (off_t
)stat
.f_bavail
);
48 strbuf_addf(out
, " (mount flags 0x%lx)\n", stat
.f_flag
);
56 #endif /* COMPAT_DISK_H */