GetFileAllocSize gets the space allocated on disk for the file. 'fname' in bytes.
(fname string)
| 19 | // GetFileAllocSize gets the space allocated on disk for the file. |
| 20 | // 'fname' in bytes. |
| 21 | func GetFileAllocSize(fname string) (uint64, error) { |
| 22 | var st syscall.Stat_t |
| 23 | |
| 24 | err := syscall.Stat(fname, &st) |
| 25 | if err != nil { |
| 26 | return 0, err //nolint:wrapcheck |
| 27 | } |
| 28 | |
| 29 | return uint64(st.Blocks) * diskBlockSize, nil //nolint:gosec |
| 30 | } |
| 31 | |
| 32 | // GetBlockSize gets the disk block size of the underlying system. |
| 33 | func GetBlockSize(path string) (uint64, error) { |