-
Notifications
You must be signed in to change notification settings - Fork 0
/
backupfs_ready_only.go
48 lines (40 loc) · 1.08 KB
/
backupfs_ready_only.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
package backupfs
import (
"io/fs"
"os"
)
func (fsys *BackupFS) Lstat(name string) (fi fs.FileInfo, err error) {
defer func() {
if err != nil {
err = &os.PathError{Op: "lstat", Path: name, Err: err}
}
}()
return fsys.base.Lstat(name)
}
// Stat returns a FileInfo describing the named file, or an error, if any happens.
// Stat only looks at the base filesystem and returns the stat of the files at the specified path
func (fsys *BackupFS) Stat(name string) (_ fs.FileInfo, err error) {
defer func() {
if err != nil {
err = &os.PathError{Op: "stat", Path: name, Err: err}
}
}()
return fsys.base.Stat(name)
}
func (fsys *BackupFS) Readlink(name string) (_ string, err error) {
defer func() {
if err != nil {
err = &os.PathError{Op: "readlink", Path: name, Err: err}
}
}()
path, err := fsys.base.Readlink(name)
if err != nil {
return "", err
}
return path, nil
}
// Open opens a file, returning it or an error, if any happens.
// This returns a ready only file
func (fsys *BackupFS) Open(name string) (File, error) {
return fsys.OpenFile(name, os.O_RDONLY, 0)
}