moby--moby/utils/fs.go

20 lines
377 B
Go
Raw Normal View History

package utils
import (
"os"
"path/filepath"
)
// TreeSize walks a directory tree and returns its total size in bytes.
func TreeSize(dir string) (size int64, err error) {
err = filepath.Walk(dir, func(d string, fileInfo os.FileInfo, e error) error {
2013-11-13 18:33:24 +00:00
// Ignore directory sizes
if fileInfo.IsDir() {
return nil
}
size += fileInfo.Size()
return nil
})
return
}