You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
348 B
21 lines
348 B
5 years ago
|
package tools
|
||
|
|
||
|
import "os"
|
||
|
|
||
|
//判断文件文件夹是否存在
|
||
|
func IsFileExist(path string) (bool, error) {
|
||
|
fileInfo, err := os.Stat(path)
|
||
|
|
||
|
if os.IsNotExist(err) {
|
||
|
return false, nil
|
||
|
}
|
||
|
//我这里判断了如果是0也算不存在
|
||
|
if fileInfo.Size() == 0 {
|
||
|
return false, nil
|
||
|
}
|
||
|
if err == nil {
|
||
|
return true, nil
|
||
|
}
|
||
|
return false, err
|
||
|
}
|