GoPLS Viewer

Home|gopls/internal/fastwalk/fastwalk_portable.go
1// 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//go:build appengine || (!linux && !darwin && !freebsd && !openbsd && !netbsd)
6// +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd
7
8package fastwalk
9
10import (
11    "io/ioutil"
12    "os"
13)
14
15// readDir calls fn for each directory entry in dirName.
16// It does not descend into directories or follow symlinks.
17// If fn returns a non-nil error, readDir returns with that error
18// immediately.
19func readDir(dirName stringfn func(dirNameentName stringtyp os.FileModeerrorerror {
20    fiserr := ioutil.ReadDir(dirName)
21    if err != nil {
22        return err
23    }
24    skipFiles := false
25    for _fi := range fis {
26        if fi.Mode().IsRegular() && skipFiles {
27            continue
28        }
29        if err := fn(dirNamefi.Name(), fi.Mode()&os.ModeType); err != nil {
30            if err == ErrSkipFiles {
31                skipFiles = true
32                continue
33            }
34            return err
35        }
36    }
37    return nil
38}
39
MembersX
readDir.BlockStmt.RangeStmt_735.fi
readDir.BlockStmt.RangeStmt_735.BlockStmt.err
ioutil
readDir.BlockStmt.fis
readDir.BlockStmt.skipFiles
Members
X