mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-22 15:59:26 +00:00
common: simplify FileExist helper (#32969)
This commit is contained in:
parent
5dd0fe2f53
commit
ccacbd1e37
1 changed files with 3 additions and 4 deletions
|
|
@ -17,6 +17,8 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
@ -24,10 +26,7 @@ import (
|
||||||
// FileExist checks if a file exists at filePath.
|
// FileExist checks if a file exists at filePath.
|
||||||
func FileExist(filePath string) bool {
|
func FileExist(filePath string) bool {
|
||||||
_, err := os.Stat(filePath)
|
_, err := os.Stat(filePath)
|
||||||
if err != nil && os.IsNotExist(err) {
|
return !errors.Is(err, fs.ErrNotExist)
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbsolutePath returns datadir + filename, or filename if it is absolute.
|
// AbsolutePath returns datadir + filename, or filename if it is absolute.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue