-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.go
84 lines (75 loc) · 2.49 KB
/
api.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
78
79
80
81
82
83
84
// SPDX-FileCopyrightText: 2024-Present Datadog, Inc
// SPDX-License-Identifier: Apache-2.0
package vfs
import (
"io"
"io/fs"
"path/filepath"
"time"
)
const (
Separator = string(filepath.Separator)
SelfDir = "."
ParentDir = ".."
FakeRoot = "/"
)
// File represents the file writer interface.
type File interface {
fs.File
io.Writer
}
// SymlinkFS extends the default filesystem abstraction to add symbolic link
// operations. (target Go 1.23)
//
// https://github.com/golang/go/issues/49580
type SymlinkFS interface {
fs.FS
// ReadLink returns the destination of the named symbolic link.
ReadLink(name string) (string, error)
// Lstat returns a FileInfo describing the file without following any
// symbolic links.
// If there is an error, it should be of type *PathError.
Lstat(name string) (fs.FileInfo, error)
}
// FileSystem extends the default read-only filesystem abstraction to add write
// operations.
type FileSystem interface {
fs.FS
fs.StatFS
fs.ReadDirFS
fs.ReadFileFS
fs.GlobFS
SymlinkFS
// Create a file.
Create(name string) (File, error)
// Mkdir creates a directory form the given path.
Mkdir(path string, perm fs.FileMode) error
// MkdirAll creats a directory path with all intermediary directories.
MkdirAll(path string, perm fs.FileMode) error
// IsDir returns true if the path is a directory.
IsDir(path string) bool
// Exists is true if the path exists in the filesystem.
Exists(path string) bool
// Chmod changes the filemode of the given path.
Chmod(name string, mode fs.FileMode) error
// Chowwn changes the owner of the given path.
Chown(name string, uid, gid int) error
// Chtimes changes the access and modification times of the given path.
Chtimes(name string, atime, mtime time.Time) error
// Symlink creates a symbolink link.
Symlink(path, name string) error
// Link creates a hardlink.
Link(path, name string) error
// RemoveAll removes all path elements from the given path from the filesystem.
RemoveAll(path string) error
// Remove remove the given path from the filesystem.
Remove(path string) error
// Resolve the given path to return a real/delinked absolute path.
Resolve(path string) (ConfirmedDir, string, error)
// Truncate changes the size of the given file.
Truncate(path string, size int64) error
// WriteFile writes given data to the given path as a file with the given filemode.
WriteFile(path string, data []byte, perm fs.FileMode) error
// WalkDir the filesystem form the given path.
WalkDir(path string, walkFn fs.WalkDirFunc) error
}