-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
67 lines (53 loc) · 1.24 KB
/
types.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
package fs
import (
"io"
"os"
"time"
)
// File interface describes a generic file methods.
type File interface {
Object
io.Reader
io.ReaderAt
io.ReaderFrom
io.WriteSeeker
io.WriterAt
io.WriterTo
io.Closer
}
type Dir interface {
Object
CreateFile(path string, perm os.FileMode, body ...[]byte) (f File, err error)
CreateDir(path string, perm os.FileMode) (d Dir, err error)
Read() ([]Object, error)
ReadFiles() ([]File, error)
}
type Object interface {
CreatedAt() time.Time
UpdatedAt() time.Time
Readable() (bool, error)
Writeable() (bool, error)
IsFile() (f File, ok bool)
IsDir() (d Dir, ok bool)
}
type Basic interface {
DirExists(path string) (exists bool, err error)
ReadFile(path string) (body []byte, err error)
OpenFile(path string) (f File, err error)
FileExists(path string) (exists bool, err error)
ReadFilesInDir(path string) (files []File, err error)
OpenDir(path string) (d Dir)
Chroot(path string) Basic
}
type Chmoder interface {
Chmod(path string, perm os.FileMode) (changed bool, err error)
}
type Chowner interface {
Chown(path string, uid interface{}, gid interface{}) (changed bool, err error)
}
type Unchrooter interface {
Unchroot(path string)
}
type Permissions interface {
Permissions() os.FileMode
}