RemoveAll finished

This commit is contained in:
mkvolkov 2022-08-20 13:21:54 +03:00
parent eb70104e76
commit 9041843981
1 changed files with 25 additions and 0 deletions

View File

@ -108,6 +108,7 @@ func (rcfs *RCFS) Remove(name string) error {
func (rcfs *RCFS) RemoveAll(path string) error {
path = rcfs.AbsPath(path)
afero.Walk(rcfs, path, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
@ -121,6 +122,30 @@ func (rcfs *RCFS) RemoveAll(path string) error {
}
})
for {
if ok, err := afero.IsEmpty(rcfs, path); err == nil {
if ok {
rcfs.Remove(path)
break
}
} else {
return err
}
afero.Walk(rcfs, path, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
}
if ok, err := afero.IsEmpty(rcfs, path); ok {
rcfs.Remove(path)
return nil
} else {
return err
}
})
}
return nil
}