Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/compat/disk.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / compat / disk.h` 57 lines ยท 1468 bytes Raw Blame History 1 #ifndef COMPAT_DISK_H 2 #define COMPAT_DISK_H 3 4 #include "abspath.h" 5 #include "gettext.h" 6 7 static int get_disk_info(struct strbuf *out) 8 { 9 struct strbuf buf = STRBUF_INIT; 10 int res = 0; 11 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; 16 17 strbuf_realpath(&buf, ".", 1); 18 if (!GetDiskFreeSpaceExA(buf.buf, &avail2caller, &total, &avail)) { 19 error(_("could not determine free disk size for '%s'"), 20 buf.buf); 21 res = -1; 22 goto cleanup; 23 } 24 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); 30 res = -1; 31 goto cleanup; 32 } 33 strbuf_addf(out, "Available space on '%s': ", buf.buf); 34 strbuf_humanise_bytes(out, avail2caller.QuadPart); 35 strbuf_addch(out, '\n'); 36 #else 37 struct statvfs stat; 38 39 strbuf_realpath(&buf, ".", 1); 40 if (statvfs(buf.buf, &stat) < 0) { 41 error_errno(_("could not determine free disk size for '%s'"), 42 buf.buf); 43 res = -1; 44 goto cleanup; 45 } 46 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); 50 #endif 51 52 cleanup: 53 strbuf_release(&buf); 54 return res; 55 } 56 57 #endif /* COMPAT_DISK_H */