decred.org/dcrwallet/v3@v3.1.0/internal/cfgutil/file.go (about) 1 // Copyright (c) 2015 The btcsuite developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package cfgutil 6 7 import "os" 8 9 // FileExists reports whether the named file or directory exists. 10 func FileExists(filePath string) (bool, error) { 11 if filePath == "" { 12 return false, nil 13 } 14 _, err := os.Stat(filePath) 15 if err != nil { 16 if os.IsNotExist(err) { 17 return false, nil 18 } 19 return false, err 20 } 21 return true, nil 22 }