You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HackBrowserData/internal/utils/fileutil/filetutil.go

36 lines
670 B

package fileutil
import (
"io/ioutil"
"os"
)
// FileExists checks if the file exists in the provided path
func FileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
if err != nil {
return false
}
return !info.IsDir()
}
// FolderExists checks if the folder exists
func FolderExists(foldername string) bool {
info, err := os.Stat(foldername)
if os.IsNotExist(err) {
return false
}
if err != nil {
return false
}
return info.IsDir()
}
// ReadFile reads the file from the provided path
func ReadFile(filename string) (string, error) {
s, err := ioutil.ReadFile(filename)
return string(s), err
}