-
Notifications
You must be signed in to change notification settings - Fork 17
/
fileinfo.go
55 lines (45 loc) · 1.2 KB
/
fileinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package memoryfs
import (
"io/fs"
"time"
)
type fileinfo struct {
name string
size int64
modified time.Time
mode fs.FileMode
sys interface{}
}
// Name is the base name of the file (without directory)
func (f fileinfo) Name() string {
return f.name
}
// Size is the size of the file in bytes (not reliable for lazy loaded files)
func (f fileinfo) Size() int64 {
return f.size
}
// Mode is the fs.FileMode of the file
func (f fileinfo) Mode() fs.FileMode {
return f.mode
}
// Info attempts to provide the fs.FileInfo for the file
func (f fileinfo) Info() (fs.FileInfo, error) {
return f, nil
}
// Type returns the type bits for the entry.
// The type bits are a subset of the usual FileMode bits, those returned by the FileMode.Type method.
func (f fileinfo) Type() fs.FileMode {
return f.Mode().Type()
}
// ModTime is the modification time of the file (not reliable for lazy loaded files)
func (f fileinfo) ModTime() time.Time {
return f.modified
}
// IsDir reports whether the entry describes a directory.
func (f fileinfo) IsDir() bool {
return f.Mode().IsDir()
}
// Sys is the underlying data source of the file (can return nil)
func (f fileinfo) Sys() interface{} {
return f.sys
}