-
Notifications
You must be signed in to change notification settings - Fork 52
/
os.go
54 lines (43 loc) · 1.18 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
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
}
// 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)
}
// Mkdir wraps os.Mkdir
func (fs OsFS) Mkdir(name string, perm os.FileMode) error {
return os.Mkdir(name, perm)
}
// 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)
}