mirror of
https://github.com/minio/minio.git
synced 2024-12-26 23:25:54 -05:00
8d98662633
Implementation overview: https://gist.github.com/klauspost/1801c858d5e0df391114436fdad6987b
36 lines
782 B
Go
36 lines
782 B
Go
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// This code is imported from "golang.org/x/tools/internal/fastwalk",
|
|
// only fastwalk.go is imported since we already implement readDir()
|
|
// with some little tweaks.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
var errSkipFile = errors.New("fastwalk: skip this file")
|
|
|
|
func readDirFn(dirName string, fn func(entName string, typ os.FileMode) error) error {
|
|
fis, err := readDir(dirName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, fi := range fis {
|
|
var mode os.FileMode
|
|
if strings.HasSuffix(fi, SlashSeparator) {
|
|
mode |= os.ModeDir
|
|
}
|
|
|
|
if err = fn(fi, mode); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|