/
operation.go
51 lines (43 loc) · 945 Bytes
/
operation.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
package types
import "strings"
// ListMode is the type for list, underlying type is int.
type ListMode uint8
const (
// ListModeDir means this list will use dir type.
ListModeDir ListMode = 1 << iota
// ListModePrefix means this list will use prefix type.
ListModePrefix
ListModePart
ListModeBlock
)
// String implement Stringer for ListMode.
//
// An object with Dir,Part will print like "dir|part"
func (l ListMode) String() string {
s := make([]string, 0)
if l.IsDir() {
s = append(s, "dir")
}
if l.IsPrefix() {
s = append(s, "prefix")
}
if l.IsPart() {
s = append(s, "part")
}
if l.IsBlock() {
s = append(s, "block")
}
return strings.Join(s, "|")
}
func (l ListMode) IsDir() bool {
return l&ListModeDir != 0
}
func (l ListMode) IsPrefix() bool {
return l&ListModePrefix != 0
}
func (l ListMode) IsPart() bool {
return l&ListModePart != 0
}
func (l ListMode) IsBlock() bool {
return l&ListModeBlock != 0
}