github.com/paketo-buildpacks/packit@v1.3.2-0.20211206231111-86b75c657449/fs/is_empty_dir.go (about)

     1  package fs
     2  
     3  import "os"
     4  
     5  // IsEmptyDir checks to see if a directory exists and is empty.
     6  func IsEmptyDir(path string) bool {
     7  	contents, err := os.ReadDir(path)
     8  	if err != nil {
     9  		return false
    10  	}
    11  
    12  	return len(contents) == 0
    13  }