Add removeAll to fakeFs

This commit is contained in:
jregan
2018-11-22 06:50:43 -08:00
parent 621ed52bab
commit eed16afb00
4 changed files with 52 additions and 6 deletions

View File

@@ -77,6 +77,21 @@ func (fs *fakeFs) MkdirAll(name string) error {
return fs.Mkdir(name)
}
// RemoveAll presumably does rm -r on a path.
// There's no error.
func (fs *fakeFs) RemoveAll(name string) error {
var toRemove []string
for k := range fs.m {
if strings.HasPrefix(k, name) {
toRemove = append(toRemove, k)
}
}
for _, k := range toRemove {
delete(fs.m, k)
}
return nil
}
// Open returns a fake file in the open state.
func (fs *fakeFs) Open(name string) (File, error) {
if _, found := fs.m[name]; !found {