Debian Codegraph @

utils/file_utils.go

raw
1 package utils
2
3 import (
4 "io/ioutil"
5 "os"
6 )
7
8 // DoesFileExist checks if a file exists.
9 func DoesFileExist(fileName string) bool {
10 _, err := os.Stat(fileName)
11 if os.IsNotExist(err) {
12 return false
13 }
14 return true
15 }
16
17 // EnsureExists creates if the file does not already exist.
18 func EnsureExists(fileName string) {
19 if DoesFileExist(fileName) {
20 return
21 }
22
23 ioutil.WriteFile(fileName, []byte(""), 0644)
24 }