aboutsummaryrefslogtreecommitdiff
path: root/fs/fs.go
blob: b06ded8ee197060d4496fd5da69a520df2da0ac2 (plain)
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
package fs

import (
	"io"
	"time"
)

type FileType string

const (
	FFile    FileType = "file"
	FDir     FileType = "dir"
	FSymlink FileType = "symlink"
)

type File interface {
	Type() FileType // Depending on type, the File must also implement RegularFile (FFile), Dir (FDir) or Symlink (FSymlink)
	Name() string
	Executable() bool // For now we will only record the executable bit instead of all permission bits
	ModTime() time.Time
	Delete() error
}

type RegularFile interface {
	File
	Open() (io.ReadWriteCloser, error)
}

type Dir interface {
	File
	Readdir() ([]File, error)
	GetChild(name string) (File, error) // Must return os.ErrNotExist, if child doesn't exist

	CreateChildFile(name string, exec bool) (RegularFile, error)
	CreateChildDir(name string) (Dir, error)
	CreateChildSymlink(name string, target string) (Symlink, error)

	RenameChild(oldname, newname string) error
}

type Symlink interface {
	File
	Readlink() (string, error)
}