FileExists checks if the file exists at the given path
(filepath string)
| 41 | |
| 42 | // FileExists checks if the file exists at the given path |
| 43 | func FileExists(filepath string) (bool, error) { |
| 44 | _, err := os.Stat(filepath) |
| 45 | if err == nil { |
| 46 | return true, nil |
| 47 | } |
| 48 | if os.IsNotExist(err) { |
| 49 | return false, nil |
| 50 | } |
| 51 | |
| 52 | return false, errors.Wrap(err, "getting file info") |
| 53 | } |
| 54 | |
| 55 | // EnsureDir creates a directory if it doesn't exist. |
| 56 | // Returns nil if the directory already exists or was successfully created. |
no outgoing calls