blob: e8ea50d65a39a9df4d329dcf6279380ea6848e36 [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001// Copyright 2016 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd
6
7package fastwalk
8
9import (
10 "io/ioutil"
11 "os"
12)
13
14// readDir calls fn for each directory entry in dirName.
15// It does not descend into directories or follow symlinks.
16// If fn returns a non-nil error, readDir returns with that error
17// immediately.
18func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error {
19 fis, err := ioutil.ReadDir(dirName)
20 if err != nil {
21 return err
22 }
23 for _, fi := range fis {
24 if err := fn(dirName, fi.Name(), fi.Mode()&os.ModeType); err != nil {
25 return err
26 }
27 }
28 return nil
29}