Skip to content

Commit 6e267ec

Browse files
author
Lord of Scripts
committed
Resolves GH-3 enhancement
1 parent 02791d4 commit 6e267ec

File tree

7 files changed

+49
-1
lines changed

7 files changed

+49
-1
lines changed

bucketfs/bitbucket_filesystem.go

+8
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ func (bfs *BitBucketFS) Remove(name string) error {
157157
return bfs.executePath("Remove", name)
158158
}
159159

160+
func (bfs *BitBucketFS) RemoveAll(path string) error {
161+
return vfs.RemoveAll(bfs, path)
162+
}
163+
160164
// Rename renames oldPath to newPath
161165
// Errors: os.LinkError
162166
func (bfs *BitBucketFS) Rename(oldPath, newPath string) error {
@@ -248,6 +252,10 @@ func (bfs *BitBucketFS) Mkdir(name string, perm os.FileMode) error {
248252
return errx
249253
}
250254

255+
func (bfs *BitBucketFS) MkdirAll(path string, perm os.FileMode) error {
256+
return vfs.MkdirAll(bfs, path, perm)
257+
}
258+
251259
// Open opens the file.
252260
// Errors: fs.PathError
253261
func (bfs *BitBucketFS) Open(name string) (vfs.File, error) {

dummy.go

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func (fs DummyFS) Remove(name string) error {
3636
return fs.err
3737
}
3838

39+
func (fs DummyFS) RemoveAll(path string) error {
40+
return fs.err
41+
}
42+
3943
// Rename returns dummy error
4044
func (fs DummyFS) Rename(oldpath, newpath string) error {
4145
return fs.err
@@ -46,6 +50,10 @@ func (fs DummyFS) Mkdir(name string, perm os.FileMode) error {
4650
return fs.err
4751
}
4852

53+
func (fs DummyFS) MkdirAll(path string, perm os.FileMode) error {
54+
return fs.err
55+
}
56+
4957
// Symlink returns dummy error
5058
func (fs DummyFS) Symlink(oldname, newname string) error {
5159
return fs.err

filesystem.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ type Filesystem interface {
2121
OpenFile(name string, flag int, perm os.FileMode) (File, error)
2222
Remove(name string) error
2323

24-
// RemoveAll(path string) error
24+
RemoveAll(path string) error
2525
Rename(oldpath, newpath string) error
2626

2727
Mkdir(name string, perm os.FileMode) error
28+
MkdirAll(path string, perm os.FileMode) error
2829

2930
Symlink(oldname, newname string) error
3031

memfs/memfs.go

+8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func (fs *MemFS) Mkdir(name string, perm os.FileMode) error {
134134
return nil
135135
}
136136

137+
func (fs *MemFS) MkdirAll(path string, perm os.FileMode) error {
138+
return vfs.MkdirAll(fs, path, perm)
139+
}
140+
137141
func (fs *MemFS) Symlink(oldname, newname string) error {
138142
file, err := fs.OpenFile(
139143
newname,
@@ -359,6 +363,10 @@ func (fs *MemFS) Remove(name string) error {
359363
return nil
360364
}
361365

366+
func (fs *MemFS) RemoveAll(path string) error {
367+
return vfs.RemoveAll(fs, path)
368+
}
369+
362370
// Rename renames (moves) a file.
363371
// Handles to the oldpath persist but might return oldpath if Name() is called.
364372
func (fs *MemFS) Rename(oldpath, newpath string) error {

mountfs/mountfs.go

+10
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ func (fs MountFS) Remove(name string) error {
111111
return mount.Remove(innerPath)
112112
}
113113

114+
func (fs MountFS) RemoveAll(path string) error {
115+
mount, innerPath := findMount(path, fs.mounts, fs.rootFS, string(fs.PathSeparator()))
116+
return mount.RemoveAll(innerPath)
117+
}
118+
114119
// Rename renames a file.
115120
// Renames across filesystems are not allowed.
116121
func (fs MountFS) Rename(oldpath, newpath string) error {
@@ -128,6 +133,11 @@ func (fs MountFS) Mkdir(name string, perm os.FileMode) error {
128133
return mount.Mkdir(innerPath, perm)
129134
}
130135

136+
func (fs MountFS) MkdirAll(path string, perm os.FileMode) error {
137+
mount, innerPath := findMount(path, fs.mounts, fs.rootFS, string(fs.PathSeparator()))
138+
return mount.MkdirAll(innerPath, perm)
139+
}
140+
131141
// Symlink creates a symlink
132142
func (fs MountFS) Symlink(oldname, newname string) error {
133143
oldMount, oldInnerName := findMount(oldname, fs.mounts, fs.rootFS, string(fs.PathSeparator()))

os.go

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ func (fs OsFS) Mkdir(name string, perm os.FileMode) error {
4747
return os.Mkdir(name, perm)
4848
}
4949

50+
func (fs OsFS) MkdirAll(path string, perm os.FileMode) error {
51+
return os.MkdirAll(path, perm)
52+
}
53+
5054
// Symlink wraps os.Symlink
5155
func (fs OsFS) Symlink(oldname, newname string) error {
5256
return os.Symlink(oldname, newname)

prefixfs/prefixfs.go

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type FS struct {
1515
}
1616

1717
// Create returns a file system that prefixes all paths and forwards to root.
18+
// Note: This is equivalent to the os.DirFS(prefix) call.
1819
func Create(root vfs.Filesystem, prefix string) *FS {
1920
return &FS{Filesystem: root, Prefix: prefix}
2021
}
@@ -37,6 +38,10 @@ func (fs *FS) Remove(name string) error {
3738
return fs.Filesystem.Remove(fs.PrefixPath(name))
3839
}
3940

41+
func (fs *FS) RemoveAll(path string) error {
42+
return fs.Filesystem.RemoveAll(fs.PrefixPath(path))
43+
}
44+
4045
// Rename implements vfs.Filesystem.
4146
func (fs *FS) Rename(oldpath, newpath string) error {
4247
return fs.Filesystem.Rename(fs.PrefixPath(oldpath), fs.PrefixPath(newpath))
@@ -47,6 +52,10 @@ func (fs *FS) Mkdir(name string, perm os.FileMode) error {
4752
return fs.Filesystem.Mkdir(fs.PrefixPath(name), perm)
4853
}
4954

55+
func (fs *FS) MkdirAll(path string, perm os.FileMode) error {
56+
return fs.Filesystem.MkdirAll(fs.PrefixPath(path), perm)
57+
}
58+
5059
// Symlink implements vfs.Filesystem.
5160
func (fs *FS) Symlink(oldname, newname string) error {
5261
return fs.Filesystem.Symlink(fs.PrefixPath(oldname), fs.PrefixPath(newname))

0 commit comments

Comments
 (0)