feat(filex): 自 go-hua/common 迁入文件目录工具并独立成包
- 运行目录定位、路径存在性、带进度回调下载、Zip 打包/解压(兼容 GBK 中文文件名) - 附单元测试、examples/filex 例程与包 README
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package filex
|
||||
|
||||
import "os"
|
||||
|
||||
// PathExists 判断一个文件或文件夹是否存在
|
||||
// 输入文件路径,根据返回的bool值来判断文件或文件夹是否存在
|
||||
func PathExists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
Reference in New Issue
Block a user