filesystem.go
func (d Directory) Enumerate(cancel <-chan struct{}) Enumerator {
	results := make(chan interface{})

	go func() {
		defer close(results)

		filepath.Walk(d.Location, func(currentLocation string, info os.FileInfo, openErr error) (err error) {
			if openErr != nil {
				err = openErr
				return
			}

			if d.Location == currentLocation {
				return
			}

			if info.IsDir() && 0 == d.Options&DirectoryOptionsRecursive {
				err = filepath.SkipDir
			}

			if d.applyOptions(currentLocation, info) {
				select {
				case results <- currentLocation:
					// Intentionally Left Blank
				case <-cancel:
					err = errors.New("directory enumeration cancelled")
				}
			}

			return
		})
	}()

	return results
}
func (d Directory) Enumerate(cancel <-chan struct{}) Enumerator {
	results := make(chan interface{})

	go func() {
		defer close(results)

		filepath.Walk(d.Location, func(currentLocation string, info os.FileInfo, openErr error) (err error) {
			if openErr != nil {
				err = openErr
				return
			}

			if d.Location == currentLocation {
				return
			}

			if info.IsDir() && 0 == d.Options&DirectoryOptionsRecursive {
				err = filepath.SkipDir
			}

			if d.applyOptions(currentLocation, info) {
				select {
				case results <- currentLocation:
					// Intentionally Left Blank
				case <-cancel:
					err = errors.New("directory enumeration cancelled")
				}
			}

			return
		})
	}()

	return results
}
func ( d Directory ) Enumerate ( cancel <- chan struct { } ) Enumerator { results := make ( chan interface { } ) go func ( ) { defer close ( results ) filepath . Walk ( d . Location , func ( currentLocation string , info os . FileInfo , openErr error ) ( err error ) { if openErr != nil { err = openErr return } if d . Location == currentLocation { return } if info . IsDir ( ) && 0 == d . Options & DirectoryOptionsRecursive { err = filepath . SkipDir } if d . applyOptions ( currentLocation , info ) { select { case results <- currentLocation : // Intentionally Left Blank case <- cancel : err = errors . New ( " " ) } } return } ) } ( ) return results }
// Enumerate lists the items in a `Directory`
Enumerate lists the items in a Directory