MCPcopy
hub / github.com/kopia/kopia / GetFileAllocSize

Function GetFileAllocSize

internal/stat/stat_bsd.go:21–30  ·  view source on GitHub ↗

GetFileAllocSize gets the space allocated on disk for the file. 'fname' in bytes.

(fname string)

Source from the content-addressed store, hash-verified

19// GetFileAllocSize gets the space allocated on disk for the file.
20// 'fname' in bytes.
21func 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.
33func GetBlockSize(path string) (uint64, error) {

Callers 1

TestGetFileAllocSizeFunction · 0.70

Calls 1

StatMethod · 0.65

Tested by 1

TestGetFileAllocSizeFunction · 0.56