diff options
author | Russ Cox <rsc@golang.org> | 2020-07-06 09:56:43 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-10-20 02:32:46 +0000 |
commit | fcb9d6b5d0ba6f5606c2b5dfc09f75e2dc5fc1e5 (patch) | |
tree | b3098b5d3de2e8fa09662efb30f5d690db166ec4 /src/os | |
parent | 9ad090c5fea60c9925b7eb30155ce01961c3537f (diff) | |
download | go-fcb9d6b5d0ba6f5606c2b5dfc09f75e2dc5fc1e5.tar.gz go-fcb9d6b5d0ba6f5606c2b5dfc09f75e2dc5fc1e5.zip |
io/fs: add FS, File, ReadDirFile; move DirEntry from os
These are the core interfaces for the io/fs design.
See #41190 and https://golang.org/s/draft-iofs-design for details.
DirEntry was left behind in the previous move from os
but is needed for ReadDirFile, so it moves in this commit.
Also apply a couple comment changes suggested in
the review of CL 261540.
For #41190.
Change-Id: I087741545139ed30b9ba5db728a0bad71129500b
Reviewed-on: https://go-review.googlesource.com/c/go/+/243908
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/dir.go | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/os/dir.go b/src/os/dir.go index a312001704..b56d998459 100644 --- a/src/os/dir.go +++ b/src/os/dir.go @@ -4,6 +4,8 @@ package os +import "io/fs" + type readdirMode int const ( @@ -62,27 +64,7 @@ func (f *File) Readdirnames(n int) (names []string, err error) { // A DirEntry is an entry read from a directory // (using the ReadDir function or a File's ReadDir method). -type DirEntry interface { - // Name returns the name of the file (or subdirectory) described by the entry. - // This name is only the final element of the path, not the entire path. - // For example, Name would return "hello.go" not "/home/gopher/hello.go". - Name() string - - // IsDir reports whether the entry describes a subdirectory. - IsDir() bool - - // Type returns the type bits for the entry. - // The type bits are a subset of the usual FileMode bits, those returned by the FileMode.Type method. - Type() FileMode - - // Info returns the FileInfo for the file or subdirectory described by the entry. - // The returned FileInfo may be from the time of the original directory read - // or from the time of the call to Info. If the file has been removed or renamed - // since the directory read, Info may return an error satisfying errors.Is(err, ErrNotExist). - // If the entry denotes a symbolic link, Info reports the information about the link itself, - // not the link's target. - Info() (FileInfo, error) -} +type DirEntry = fs.DirEntry // ReadDir reads the contents of the directory associated with the file f // and returns a slice of DirEntry values in directory order. |