From 263a98f9add1ad140e74a93aabce8c6559934f2b Mon Sep 17 00:00:00 2001 From: spf13 Date: Fri, 31 Oct 2014 23:39:14 -0400 Subject: [PATCH] MemDir now reports a size --- httpFs.go | 1 + memfile.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/httpFs.go b/httpFs.go index af44344..a08f0bd 100644 --- a/httpFs.go +++ b/httpFs.go @@ -36,6 +36,7 @@ func (d httpDir) Open(name string) (http.File, error) { if dir == "" { dir = "." } + f, err := d.fs.Open(filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name)))) if err != nil { return nil, err diff --git a/memfile.go b/memfile.go index fcf80d2..4815c6b 100644 --- a/memfile.go +++ b/memfile.go @@ -191,8 +191,13 @@ type InMemoryFileInfo struct { // Implements os.FileInfo func (s *InMemoryFileInfo) Name() string { return s.file.Name() } -func (s *InMemoryFileInfo) Size() int64 { return int64(len(s.file.data)) } func (s *InMemoryFileInfo) Mode() os.FileMode { return s.file.mode } func (s *InMemoryFileInfo) ModTime() time.Time { return s.file.modtime } func (s *InMemoryFileInfo) IsDir() bool { return s.file.dir } func (s *InMemoryFileInfo) Sys() interface{} { return nil } +func (s *InMemoryFileInfo) Size() int64 { + if s.IsDir() { + return int64(42) + } + return int64(len(s.file.data)) +}