github.com/reds/docker@v1.11.2-rc1/pkg/directory/directory_windows.go (about)

     1  // +build windows
     2  
     3  package directory
     4  
     5  import (
     6  	"os"
     7  	"path/filepath"
     8  )
     9  
    10  // Size walks a directory tree and returns its total size in bytes.
    11  func Size(dir string) (size int64, err error) {
    12  	err = filepath.Walk(dir, func(d string, fileInfo os.FileInfo, e error) error {
    13  		// Ignore directory sizes
    14  		if fileInfo == nil {
    15  			return nil
    16  		}
    17  
    18  		s := fileInfo.Size()
    19  		if fileInfo.IsDir() || s == 0 {
    20  			return nil
    21  		}
    22  
    23  		size += s
    24  
    25  		return nil
    26  	})
    27  	return
    28  }