MCPcopy
hub / github.com/rclone/rclone / New

Function New

lib/diskusage/diskusage_unix.go:12–27  ·  view source on GitHub ↗

New returns the disk status for dir. May return Unsupported error if it doesn't work on this platform.

(dir string)

Source from the content-addressed store, hash-verified

10//
11// May return Unsupported error if it doesn't work on this platform.
12func New(dir string) (info Info, err error) {
13 var statfs unix.Statfs_t
14 err = unix.Statfs(dir, &statfs)
15 if err != nil {
16 return info, err
17 }
18 // Note that these can be different sizes on different OSes so
19 // we upcast them all to uint64
20 //nolint:unconvert
21 info.Free = uint64(statfs.Bfree) * uint64(statfs.Bsize)
22 //nolint:unconvert
23 info.Available = uint64(statfs.Bavail) * uint64(statfs.Bsize)
24 //nolint:unconvert
25 info.Total = uint64(statfs.Blocks) * uint64(statfs.Bsize)
26 return info, nil
27}

Callers 4

minFreeSpaceQuotaOKMethod · 0.92
rcDuFunction · 0.92
TestNewFunction · 0.70

Calls 1

StatfsMethod · 0.45

Tested by 2

TestNewFunction · 0.56