mirror of
https://github.com/golang/go
synced 2024-11-14 15:10:54 -07:00
fc821667dd
The two methods act the same, so make their documentation similar so that people don't think they act differently. Change-Id: If224692ef50870faf855d789380a614d1e724132 Reviewed-on: https://go-review.googlesource.com/c/go/+/188137 Reviewed-by: Rob Pike <r@golang.org>
50 lines
2.0 KiB
Go
50 lines
2.0 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 the contents of the directory associated with file
|
|
// and returns a slice of up to n names of files in the directory,
|
|
// in directory order. Subsequent calls on the same file will yield
|
|
// further names.
|
|
//
|
|
// 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)
|
|
}
|