mirror of https://github.com/spf13/afero.git
MemDir now reports a size
This commit is contained in:
parent
f5d2472495
commit
263a98f9ad
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue