Feat: handle aria2 download complete
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@@ -28,3 +29,18 @@ func CreatNestedFile(path string) (*os.File, error) {
|
||||
|
||||
return os.Create(path)
|
||||
}
|
||||
|
||||
// IsEmpty 返回给定目录是否为空目录
|
||||
func IsEmpty(name string) (bool, error) {
|
||||
f, err := os.Open(name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.Readdirnames(1) // Or f.Readdir(1)
|
||||
if err == io.EOF {
|
||||
return true, nil
|
||||
}
|
||||
return false, err // Either not empty or error, suits both cases
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user