Files
varia-go/shared/files.go
2025-10-27 22:51:42 +01:00

23 lines
374 B
Go

package shared
import (
"os"
"path/filepath"
"strings"
)
func FileNameWithoutExt(fileName string) string {
return strings.TrimSuffix(fileName, filepath.Ext(fileName))
}
func FileExists(filePath string) (bool, error) {
info, err := os.Stat(filePath)
if err == nil {
return !info.IsDir(), nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}