4 #include "git-compat-util.h"
8 static int get_disk_info(struct strbuf
*out
)
10 struct strbuf buf
= STRBUF_INIT
;
13 #ifdef GIT_WINDOWS_NATIVE
14 char volume_name
[MAX_PATH
], fs_name
[MAX_PATH
];
15 DWORD serial_number
, component_length
, flags
;
16 ULARGE_INTEGER avail2caller
, total
, avail
;
18 strbuf_realpath(&buf
, ".", 1);
19 if (!GetDiskFreeSpaceExA(buf
.buf
, &avail2caller
, &total
, &avail
)) {
20 error(_("could not determine free disk size for '%s'"),
26 strbuf_setlen(&buf
, offset_1st_component(buf
.buf
));
27 if (!GetVolumeInformationA(buf
.buf
, volume_name
, sizeof(volume_name
),
28 &serial_number
, &component_length
, &flags
,
29 fs_name
, sizeof(fs_name
))) {
30 error(_("could not get info for '%s'"), buf
.buf
);
34 strbuf_addf(out
, "Available space on '%s': ", buf
.buf
);
35 strbuf_humanise_bytes(out
, avail2caller
.QuadPart
);
36 strbuf_addch(out
, '\n');
40 strbuf_realpath(&buf
, ".", 1);
41 if (statvfs(buf
.buf
, &stat
) < 0) {
42 error_errno(_("could not determine free disk size for '%s'"),
48 strbuf_addf(out
, "Available space on '%s': ", buf
.buf
);
49 strbuf_humanise_bytes(out
, (off_t
)stat
.f_bsize
* (off_t
)stat
.f_bavail
);
50 strbuf_addf(out
, " (mount flags 0x%lx)\n", stat
.f_flag
);
58 #endif /* COMPAT_DISK_H */