forked from 3JoB/vfs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os.go
77 lines (62 loc) · 1.81 KB
/
os.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
68
69
70
71
72
73
74
75
76
77
package vfs
import (
"io/ioutil"
"os"
)
// OsFS represents a filesystem backed by the filesystem of the underlying OS.
type OsFS struct{}
// OS returns a filesystem backed by the filesystem of the os. It wraps os.* stdlib operations.
func OS() *OsFS {
return &OsFS{}
}
// PathSeparator returns the path separator
func (fs OsFS) PathSeparator() uint8 {
return os.PathSeparator
}
// Open wraps os.Open
func (fs OsFS) Open(name string) (File, error) {
return os.Open(name)
}
// OpenFile wraps os.OpenFile
func (fs OsFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
return os.OpenFile(name, flag, perm)
}
// Remove wraps os.Remove
func (fs OsFS) Remove(name string) error {
return os.Remove(name)
}
// RemoveAll removes path and any children it contains.
// It removes everything it can but returns the first error
// it encounters. If the path does not exist, RemoveAll
// returns nil (no error).
// If there is an error, it will be of type *PathError.
func (fs OsFS) RemoveAll(name string) error {
return os.RemoveAll(name)
}
// Mkdir wraps os.Mkdir
func (fs OsFS) Mkdir(name string, perm os.FileMode) error {
return os.Mkdir(name, perm)
}
func (fs OsFS) MkdirAll(path string, perm os.FileMode) error {
return os.MkdirAll(path, perm)
}
// Symlink wraps os.Symlink
func (fs OsFS) Symlink(oldname, newname string) error {
return os.Symlink(oldname, newname)
}
// Rename wraps os.Rename
func (fs OsFS) Rename(oldpath, newpath string) error {
return os.Rename(oldpath, newpath)
}
// Stat wraps os.Stat
func (fs OsFS) Stat(name string) (os.FileInfo, error) {
return os.Stat(name)
}
// Lstat wraps os.Lstat
func (fs OsFS) Lstat(name string) (os.FileInfo, error) {
return os.Lstat(name)
}
// ReadDir wraps ioutil.ReadDir
func (fs OsFS) ReadDir(path string) ([]os.FileInfo, error) {
return ioutil.ReadDir(path)
}