aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorCharlie Moog <moogcharlie@gmail.com>2021-03-24 19:17:03 -0500
committerIan Lance Taylor <iant@golang.org>2021-04-06 04:48:09 +0000
commita25c58462992704dbb6819769f530b6cc6a8ebe3 (patch)
tree8c8f5ccd307a5e1cbfeec03c0f2ec8bfd6bfff0f /src/os
parentd8306ee1f9a3221b2a70663a3d127d72c17df05e (diff)
downloadgo-a25c58462992704dbb6819769f530b6cc6a8ebe3.tar.gz
go-a25c58462992704dbb6819769f530b6cc6a8ebe3.zip
os: implement fs.StatFS for os.DirFS
Change-Id: I1d7382bf522aeda7148431b348f6ab9a162be097 Reviewed-on: https://go-review.googlesource.com/c/go/+/304531 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/os')
-rw-r--r--src/os/file.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/os/file.go b/src/os/file.go
index ebeb0d0ac9..e717f171e7 100644
--- a/src/os/file.go
+++ b/src/os/file.go
@@ -651,6 +651,17 @@ func (dir dirFS) Open(name string) (fs.File, error) {
return f, nil
}
+func (dir dirFS) Stat(name string) (fs.FileInfo, error) {
+ if !fs.ValidPath(name) || runtime.GOOS == "windows" && containsAny(name, `\:`) {
+ return nil, &PathError{Op: "stat", Path: name, Err: ErrInvalid}
+ }
+ f, err := Stat(string(dir) + "/" + name)
+ if err != nil {
+ return nil, err
+ }
+ return f, nil
+}
+
// ReadFile reads the named file and returns the contents.
// A successful call returns err == nil, not err == EOF.
// Because ReadFile reads the whole file, it does not treat an EOF from Read