forked from Elara6331/infinitime
Fix RemoveAll() and MkdirAll() functions
This commit is contained in:
parent
3e9957d419
commit
b476853dc0
19
blefs/all.go
19
blefs/all.go
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user