26 lines
444 B
Go
26 lines
444 B
Go
package files
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func IsFileExists(fileLocation string) bool {
|
|
if _, err := os.Stat(fileLocation); errors.Is(err, os.ErrNotExist) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func GetParentDir(fileLocation string) string {
|
|
fileLocation = strings.ReplaceAll(fileLocation, "\\", "/")
|
|
indexOfSlash := strings.LastIndex(fileLocation, "/")
|
|
if indexOfSlash > 0 {
|
|
return fileLocation[:indexOfSlash]
|
|
}
|
|
|
|
return ""
|
|
}
|