forked from ranveerkunal/memfs
/
fileinfo.go
62 lines (49 loc) · 1.07 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
56
57
58
59
60
61
62
// Copyright (c) 2013 The Go Authors. All rights reserved.
// Copyright (c) 2013 memfs Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package memfs
import (
"os"
"time"
)
type memFileInfo struct {
content []byte
name string
size int64
mode os.FileMode
modTime time.Time
isDir bool
path string
fs *memFileSystem
}
func (fi *memFileInfo) Name() string {
return fi.name
}
func (fi *memFileInfo) Size() int64 {
return fi.size
}
func (fi *memFileInfo) Mode() os.FileMode {
return fi.mode
}
func (fi *memFileInfo) ModTime() time.Time {
return fi.modTime
}
func (fi *memFileInfo) IsDir() bool {
return fi.isDir
}
func (fi *memFileInfo) Sys() interface{} {
return nil
}
type fileInfoSorter struct {
infos []os.FileInfo
}
func (s *fileInfoSorter) Len() int {
return len(s.infos)
}
func (s *fileInfoSorter) Swap(i, j int) {
s.infos[i], s.infos[j] = s.infos[j], s.infos[i]
}
func (s *fileInfoSorter) Less(i, j int) bool {
return s.infos[i].Name() < s.infos[j].Name()
}