...
1
16
17
21
22 package filesystem
23
24 import (
25 "os"
26 "path/filepath"
27 "time"
28 )
29
30
31 type Filesystem interface {
32
33 Stat(name string) (os.FileInfo, error)
34 Create(name string) (File, error)
35 Open(name string) (File, error)
36 OpenFile(name string, flag int, perm os.FileMode) (File, error)
37 Rename(oldpath, newpath string) error
38 MkdirAll(path string, perm os.FileMode) error
39 Chtimes(name string, atime time.Time, mtime time.Time) error
40 RemoveAll(path string) error
41 Remove(name string) error
42 Chmod(name string, mode os.FileMode) error
43 Getwd() (dir string, err error)
44
45
46 ReadFile(filename string) ([]byte, error)
47 WriteFile(filename string, data []byte, perm os.FileMode) error
48 TempDir(dir, prefix string) (string, error)
49 TempFile(dir, prefix string) (File, error)
50 ReadDir(dirname string) ([]os.FileInfo, error)
51 Walk(root string, walkFn filepath.WalkFunc) error
52 }
53
54
55
56 type File interface {
57
58 Name() string
59 Write(b []byte) (n int, err error)
60 WriteString(s string) (n int, err error)
61 Sync() error
62 Close() error
63 Read(b []byte) (n int, err error)
64 Readdir(n int) ([]os.FileInfo, error)
65 }
66
View as plain text