vendor: cadvisor v0.38.4

This commit is contained in:
David Porter
2020-11-13 19:52:57 +00:00
parent ec734aced7
commit 8af7405f17
396 changed files with 73154 additions and 18510 deletions

View File

@@ -1,54 +1,66 @@
// +build windows
package godirwalk
import (
"os"
import "os"
"github.com/pkg/errors"
)
// MinimumScratchBufferSize specifies the minimum size of the scratch buffer
// that ReadDirents, ReadDirnames, Scanner, and Walk will use when reading file
// entries from the operating system. During program startup it is initialized
// to the result from calling `os.Getpagesize()` for non Windows environments,
// and 0 for Windows.
var MinimumScratchBufferSize = 0
// The functions in this file are mere wrappers of what is already provided by
// standard library, in order to provide the same API as this library provides.
//
// The scratch buffer argument is ignored by this architecture.
//
// Please send PR or link to article if you know of a more performant way of
// enumerating directory contents and mode types on Windows.
func newScratchBuffer() []byte { return nil }
func readdirents(osDirname string, _ []byte) (Dirents, error) {
func readDirents(osDirname string, _ []byte) ([]*Dirent, error) {
dh, err := os.Open(osDirname)
if err != nil {
return nil, errors.Wrap(err, "cannot Open")
return nil, err
}
fileinfos, err := dh.Readdir(0)
if er := dh.Close(); err == nil {
err = er
}
fileinfos, err := dh.Readdir(-1)
if err != nil {
return nil, errors.Wrap(err, "cannot Readdir")
_ = dh.Close()
return nil, err
}
entries := make(Dirents, len(fileinfos))
for i, info := range fileinfos {
entries[i] = &Dirent{name: info.Name(), modeType: info.Mode() & os.ModeType}
entries := make([]*Dirent, len(fileinfos))
for i, fi := range fileinfos {
entries[i] = &Dirent{
name: fi.Name(),
path: osDirname,
modeType: fi.Mode() & os.ModeType,
}
}
if err = dh.Close(); err != nil {
return nil, err
}
return entries, nil
}
func readdirnames(osDirname string, _ []byte) ([]string, error) {
func readDirnames(osDirname string, _ []byte) ([]string, error) {
dh, err := os.Open(osDirname)
if err != nil {
return nil, errors.Wrap(err, "cannot Open")
return nil, err
}
entries, err := dh.Readdirnames(0)
if er := dh.Close(); err == nil {
err = er
}
fileinfos, err := dh.Readdir(-1)
if err != nil {
return nil, errors.Wrap(err, "cannot Readdirnames")
_ = dh.Close()
return nil, err
}
entries := make([]string, len(fileinfos))
for i, fi := range fileinfos {
entries[i] = fi.Name()
}
if err = dh.Close(); err != nil {
return nil, err
}
return entries, nil
}