diff --git a/blefs/all.go b/blefs/all.go index 56d82c4..7ba9809 100644 --- a/blefs/all.go +++ b/blefs/all.go @@ -38,12 +38,19 @@ func (blefs *FS) removeAllChildren(path string) error { } for _, entry := range list { - if entry.IsDir() { - err = blefs.removeAllChildren(filepath.Join(path, entry.Name())) - } else { - err = blefs.Remove(path) + name := entry.Name() + + if name == "." || name == ".." { + continue } - if err != nil { + entryPath := filepath.Join(path, name) + + if entry.IsDir() { + err = blefs.removeAllChildren(entryPath) + } else { + err = blefs.Remove(entryPath) + } + if err != nil && err.(FSError).Code != -2 { return err } } @@ -58,7 +65,7 @@ func (blefs *FS) MkdirAll(path string) error { splitPath := strings.Split(path, "/") for i := 1; i < len(splitPath); i++ { - curPath := strings.Join(splitPath[0:i], "/") + curPath := strings.Join(splitPath[0:i+1], "/") err := blefs.Mkdir(curPath) if err != nil && err.(FSError).Code != -17 {