-
Notifications
You must be signed in to change notification settings - Fork 44
/
fileinfo.go
98 lines (82 loc) · 2.26 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package rpm
import (
"os"
"time"
)
// File flags make up some attributes of files depending on how they were
// specified in the rpmspec
const (
FileFlagNone = 0
FileFlagConfig = (1 << 0) // %%config
FileFlagDoc = (1 << 1) // %%doc
FileFlagIcon = (1 << 2) // %%donotuse
FileFlagMissingOk = (1 << 3) // %%config(missingok)
FileFlagNoReplace = (1 << 4) // %%config(noreplace)
FileFlagGhost = (1 << 6) // %%ghost
FileFlagLicense = (1 << 7) // %%license
FileFlagReadme = (1 << 8) // %%readme
FileFlagPubkey = (1 << 11) // %%pubkey
FileFlagArtifact = (1 << 12) // %%artifact
)
// A FileInfo describes a file in an rpm package.
//
// FileInfo implements the os.FileInfo interface.
type FileInfo struct {
name string
size int64
mode os.FileMode
modTime time.Time
flags int64
owner string
group string
digest string
linkname string
}
// compile-time check that rpm.FileInfo implements os.FileInfo interface
var _ os.FileInfo = new(FileInfo)
func (f *FileInfo) String() string {
return f.Name()
}
// Name is the full path of a file in an rpm package.
func (f *FileInfo) Name() string {
return f.name
}
// Size is the size in bytes of a file in an rpm package.
func (f *FileInfo) Size() int64 {
return f.size
}
// Mode is the file mode in bits of a file in an rpm package.
func (f *FileInfo) Mode() os.FileMode {
return f.mode
}
// ModTime is the modification time of a file in an rpm package.
func (f *FileInfo) ModTime() time.Time {
return f.modTime
}
// IsDir returns true if a file is a directory in an rpm package.
func (f *FileInfo) IsDir() bool {
return f.mode.IsDir()
}
func (f *FileInfo) Flags() int64 {
return f.flags
}
// Owner is the name of the owner of a file in an rpm package.
func (f *FileInfo) Owner() string {
return f.owner
}
// Group is the name of the owner group of a file in an rpm package.
func (f *FileInfo) Group() string {
return f.group
}
// Digest is the md5sum of a file in an rpm package.
func (f *FileInfo) Digest() string {
return f.digest
}
// Linkname is the link target of a link file in an rpm package.
func (f *FileInfo) Linkname() string {
return f.linkname
}
// Sys implements os.FileInfo and always returns nil.
func (f *FileInfo) Sys() interface{} {
return nil
}