-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs.go
More file actions
50 lines (40 loc) · 1023 Bytes
/
Copy pathfs.go
File metadata and controls
50 lines (40 loc) · 1023 Bytes
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
package livefile
import (
"io"
"io/fs"
"os"
)
type WriteFS interface {
Open(name string) (ReadSeekFile, error)
OpenFile(name string, flag int, perm fs.FileMode) (WriteFile, error)
MkdirAll(path string, perm fs.FileMode) error
Remove(name string) error
}
type WriteFile interface {
ReadSeekFile
io.Writer
io.WriterAt
Truncate(size int64) error
Sync() error
}
type ReadSeekFile interface {
fs.File
io.Seeker
}
// osFileSystem implements WriteFS using the os package
type osFileSystem struct{}
func (osfs osFileSystem) Open(name string) (ReadSeekFile, error) {
return os.Open(name)
}
func (osfs osFileSystem) OpenFile(name string, flag int, perm fs.FileMode) (WriteFile, error) {
return os.OpenFile(name, flag, perm)
}
func (osfs osFileSystem) OpenRead(name string) (ReadSeekFile, error) {
return os.Open(name)
}
func (osfs osFileSystem) MkdirAll(path string, perm fs.FileMode) error {
return os.MkdirAll(path, perm)
}
func (osfs osFileSystem) Remove(name string) error {
return os.Remove(name)
}