Skip to content

Commit b4738c5

Browse files
committed
filesystem: split up SymlinkFS
1 parent 28078f2 commit b4738c5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

internal/filesystem/filesystem.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,20 @@ type (
3737
Remove(name string) error
3838
}
3939
SymlinkFS interface {
40+
LinkStater
41+
LinkMaker
42+
LinkReader
43+
}
44+
LinkStater interface {
4045
fs.FS
4146
Lstat(name string) (fs.FileInfo, error)
47+
}
48+
LinkMaker interface {
49+
fs.FS
4250
Symlink(oldname, newname string) error
51+
}
52+
LinkReader interface {
53+
fs.FS
4354
Readlink(name string) (string, error)
4455
}
4556
RenameFS interface {
@@ -153,23 +164,23 @@ func Remove(fsys fs.FS, name string) error {
153164
}
154165

155166
func Lstat(fsys fs.FS, name string) (fs.FileInfo, error) {
156-
if fsys, ok := fsys.(SymlinkFS); ok {
167+
if fsys, ok := fsys.(LinkStater); ok {
157168
return fsys.Lstat(name)
158169
}
159170
const op = "lstat"
160171
return nil, unsupportedOpErr(op, name)
161172
}
162173

163174
func Symlink(fsys fs.FS, oldname, newname string) error {
164-
if fsys, ok := fsys.(SymlinkFS); ok {
175+
if fsys, ok := fsys.(LinkMaker); ok {
165176
return fsys.Symlink(oldname, newname)
166177
}
167178
const op = "symlink"
168179
return unsupportedOpErr2(op, oldname, newname)
169180
}
170181

171182
func Readlink(fsys fs.FS, name string) (string, error) {
172-
if fsys, ok := fsys.(SymlinkFS); ok {
183+
if fsys, ok := fsys.(LinkReader); ok {
173184
return fsys.Readlink(name)
174185
}
175186
const op = "readlink"

0 commit comments

Comments
 (0)