mirror of
https://github.com/autc04/Retro68.git
synced 2024-12-02 18:53:22 +00:00
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)
|
|
}
|