MemDir now reports a size

This commit is contained in:
spf13 2014-10-31 23:39:14 -04:00
parent f5d2472495
commit 263a98f9ad
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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))
}