-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfile.go
52 lines (42 loc) · 938 Bytes
/
file.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
package noodle
import (
"os"
"time"
)
var _ os.FileInfo = (*FileInfo)(nil)
// FileInfo is a concrete struct that implements os.FileInfo interface
// Its fields have the awkward File* prefix to avoid conflict with os.FileInfo interface
type FileInfo struct {
FileName string
FileSize int64
FileMode os.FileMode
FileModTime time.Time
FileIsDir bool
}
func NewFileInfo(info os.FileInfo) *FileInfo {
return &FileInfo{
FileName: info.Name(),
FileSize: info.Size(),
FileMode: info.Mode(),
FileModTime: info.ModTime(),
FileIsDir: info.IsDir(),
}
}
func (i *FileInfo) Name() string {
return i.FileName
}
func (i *FileInfo) Size() int64 {
return i.FileSize
}
func (i *FileInfo) Mode() os.FileMode {
return i.FileMode
}
func (i *FileInfo) ModTime() time.Time {
return i.FileModTime
}
func (i *FileInfo) IsDir() bool {
return i.FileIsDir
}
func (i *FileInfo) Sys() interface{} {
return nil
}