23 lines
374 B
Go
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
|
|
}
|