incredible-go-core/pkg/io/files/file_exists_checker.go

26 lines
444 B
Go
Raw Normal View History

2024-06-20 19:06:29 +02:00
package files
import (
"errors"
"os"
2024-06-21 17:39:35 +02:00
"strings"
2024-06-20 19:06:29 +02:00
)
func IsFileExists(fileLocation string) bool {
if _, err := os.Stat(fileLocation); errors.Is(err, os.ErrNotExist) {
return false
}
return true
}
2024-06-21 17:39:35 +02:00
func GetParentDir(fileLocation string) string {
fileLocation = strings.ReplaceAll(fileLocation, "\\", "/")
indexOfSlash := strings.LastIndex(fileLocation, "/")
if indexOfSlash > 0 {
return fileLocation[:indexOfSlash]
}
return ""
}