7 static int get_disk_info(struct strbuf
*out
)
9 struct strbuf buf
= STRBUF_INIT
;
12 #ifdef GIT_WINDOWS_NATIVE
13 char volume_name
[MAX_PATH
], fs_name
[MAX_PATH
];
14 DWORD serial_number
, component_length
, flags
;
15 ULARGE_INTEGER avail2caller
, total
, avail
;
17 strbuf_realpath(&buf
, ".", 1);
18 if (!GetDiskFreeSpaceExA(buf
.buf
, &avail2caller
, &total
, &avail
)) {
19 error(_("could not determine free disk size for '%s'"),
25 strbuf_setlen(&buf
, offset_1st_component(buf
.buf
));
26 if (!GetVolumeInformationA(buf
.buf
, volume_name
, sizeof(volume_name
),
27 &serial_number
, &component_length
, &flags
,
28 fs_name
, sizeof(fs_name
))) {
29 error(_("could not get info for '%s'"), buf
.buf
);
33 strbuf_addf(out
, "Available space on '%s': ", buf
.buf
);
34 strbuf_humanise_bytes(out
, avail2caller
.QuadPart
);
35 strbuf_addch(out
, '\n');
39 strbuf_realpath(&buf
, ".", 1);
40 if (statvfs(buf
.buf
, &stat
) < 0) {
41 error_errno(_("could not determine free disk size for '%s'"),
47 strbuf_addf(out
, "Available space on '%s': ", buf
.buf
);
48 strbuf_humanise_bytes(out
, (off_t
)stat
.f_bsize
* (off_t
)stat
.f_bavail
);
49 strbuf_addf(out
, " (mount flags 0x%lx)\n", stat
.f_flag
);
57 #endif /* COMPAT_DISK_H */