aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-16 23:20:23 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-16 23:23:43 +0200
commit1d678dfdfa026968dbb19795c9bed16385603b21 (patch)
treecac862609d0103ee30da39cd0054b11884248e9d /vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go
parent131a862d313f12808d63e832126317a27226940b (diff)
downloadgit-bug-1d678dfdfa026968dbb19795c9bed16385603b21.tar.gz
vendor dependencies with dep
Diffstat (limited to 'vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go')
-rw-r--r--vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go b/vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go
new file mode 100644
index 00000000..df071d11
--- /dev/null
+++ b/vendor/github.com/shurcooL/httpfs/vfsutil/vfsutil.go
@@ -0,0 +1,39 @@
+// Package vfsutil implements some I/O utility functions for http.FileSystem.
+package vfsutil
+
+import (
+ "io/ioutil"
+ "net/http"
+ "os"
+)
+
+// ReadDir reads the contents of the directory associated with file and
+// returns a slice of FileInfo values in directory order.
+func ReadDir(fs http.FileSystem, name string) ([]os.FileInfo, error) {
+ f, err := fs.Open(name)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ return f.Readdir(0)
+}
+
+// Stat returns the FileInfo structure describing file.
+func Stat(fs http.FileSystem, name string) (os.FileInfo, error) {
+ f, err := fs.Open(name)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ return f.Stat()
+}
+
+// ReadFile reads the file named by path from fs and returns the contents.
+func ReadFile(fs http.FileSystem, path string) ([]byte, error) {
+ rc, err := fs.Open(path)
+ if err != nil {
+ return nil, err
+ }
+ defer rc.Close()
+ return ioutil.ReadAll(rc)
+}