Fix RemoveAll() and MkdirAll() functions

This commit is contained in:
Elara 2022-10-16 12:39:11 -07:00
parent 3e9957d419
commit b476853dc0

View File

@ -38,12 +38,19 @@ func (blefs *FS) removeAllChildren(path string) error {
} }
for _, entry := range list { for _, entry := range list {
if entry.IsDir() { name := entry.Name()
err = blefs.removeAllChildren(filepath.Join(path, entry.Name()))
} else { if name == "." || name == ".." {
err = blefs.Remove(path) 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 return err
} }
} }
@ -58,7 +65,7 @@ func (blefs *FS) MkdirAll(path string) error {
splitPath := strings.Split(path, "/") splitPath := strings.Split(path, "/")
for i := 1; i < len(splitPath); i++ { for i := 1; i < len(splitPath); i++ {
curPath := strings.Join(splitPath[0:i], "/") curPath := strings.Join(splitPath[0:i+1], "/")
err := blefs.Mkdir(curPath) err := blefs.Mkdir(curPath)
if err != nil && err.(FSError).Code != -17 { if err != nil && err.(FSError).Code != -17 {