Mike Schwörer
06d81f1682
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m31s
37 lines
580 B
Go
37 lines
580 B
Go
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
|
|
}
|