v0.0.289 fsext
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m31s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m31s
This commit is contained in:
36
fsext/exists.go
Normal file
36
fsext/exists.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package fsext
|
||||
|
||||
import "os"
|
||||
|
||||
func PathExists(fp string) (bool, error) {
|
||||
_, err := os.Stat(fp)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
func FileExists(fp string) (bool, error) {
|
||||
stat, err := os.Stat(fp)
|
||||
if err == nil {
|
||||
return !stat.IsDir(), nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
func DirectoryExists(fp string) (bool, error) {
|
||||
stat, err := os.Stat(fp)
|
||||
if err == nil {
|
||||
return stat.IsDir(), nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
Reference in New Issue
Block a user