mirror of
https://github.com/golang/go
synced 2024-11-19 11:24:51 -07:00
664c4a1f87
Code movement only. If someone finds function 'foo' in "foo_linux.go", they will expect that the Window version of 'foo' exists in "foo_windows.go". Current code doesn't follow this manner. For example, 'sameFile' exists in "file_unix.go", "stat_plan9.go" and "types_windows.go". The CL address that problem by following rules: * readdir family => dir.go, dir_$GOOS.go * stat family => stat.go, stat_$GOOS.go * path-functions => path_$GOOS.go * sameFile => types.go, types_$GOOS.go * process-functions => exec.go, exec_$GOOS.go * hostname => sys.go, sys_$GOOS.go Change-Id: Ic3c64663ce0b2a364d7a414351cd3c772e70187b Reviewed-on: https://go-review.googlesource.com/27035 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
47 lines
1.8 KiB
Go
47 lines
1.8 KiB
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.
|
|
|
|
package os
|
|
|
|
// Readdir reads the contents of the directory associated with file and
|
|
// returns a slice of up to n FileInfo values, as would be returned
|
|
// by Lstat, in directory order. Subsequent calls on the same file will yield
|
|
// further FileInfos.
|
|
//
|
|
// If n > 0, Readdir returns at most n FileInfo structures. In this case, if
|
|
// Readdir returns an empty slice, it will return a non-nil error
|
|
// explaining why. At the end of a directory, the error is io.EOF.
|
|
//
|
|
// If n <= 0, Readdir returns all the FileInfo from the directory in
|
|
// a single slice. In this case, if Readdir succeeds (reads all
|
|
// the way to the end of the directory), it returns the slice and a
|
|
// nil error. If it encounters an error before the end of the
|
|
// directory, Readdir returns the FileInfo read until that point
|
|
// and a non-nil error.
|
|
func (f *File) Readdir(n int) ([]FileInfo, error) {
|
|
if f == nil {
|
|
return nil, ErrInvalid
|
|
}
|
|
return f.readdir(n)
|
|
}
|
|
|
|
// Readdirnames reads and returns a slice of names from the directory f.
|
|
//
|
|
// If n > 0, Readdirnames returns at most n names. In this case, if
|
|
// Readdirnames returns an empty slice, it will return a non-nil error
|
|
// explaining why. At the end of a directory, the error is io.EOF.
|
|
//
|
|
// If n <= 0, Readdirnames returns all the names from the directory in
|
|
// a single slice. In this case, if Readdirnames succeeds (reads all
|
|
// the way to the end of the directory), it returns the slice and a
|
|
// nil error. If it encounters an error before the end of the
|
|
// directory, Readdirnames returns the names read until that point and
|
|
// a non-nil error.
|
|
func (f *File) Readdirnames(n int) (names []string, err error) {
|
|
if f == nil {
|
|
return nil, ErrInvalid
|
|
}
|
|
return f.readdirnames(n)
|
|
}
|