-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileinfo.go
50 lines (40 loc) · 1.06 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
// SPDX-FileCopyrightText: 2022 Weston Schmidt <[email protected]>
// SPDX-License-Identifier: Apache-2.0
package githubfs
import (
"io/fs"
"time"
)
// ensure the fileInfo matches the interface.
var _ fs.FileInfo = (*fileInfo)(nil)
// fileInfo describes a file and is returned by Stat.
type fileInfo struct {
name string
size int64
modTime time.Time
mode fs.FileMode
}
// Name returns the base name of the file.
func (fi *fileInfo) Name() string {
return fi.name
}
// Size returns the length in bytes for regular files; system-dependent for others.
func (fi *fileInfo) Size() int64 {
return fi.size
}
// Mode returns the file mode bits.
func (fi *fileInfo) Mode() fs.FileMode {
return fi.mode
}
// ModTime returns the modification time.
func (fi *fileInfo) ModTime() time.Time {
return fi.modTime
}
// IsDir returns the abbreviation for Mode().IsDir().
func (fi *fileInfo) IsDir() bool {
return fi.mode&fs.ModeDir > 0
}
// Sys returns the underlying data source (can return nil). (Always nil).
func (fi *fileInfo) Sys() any {
return nil
}