improved file read/copy logic

This commit is contained in:
zomo
2025-12-24 13:58:02 -06:00
parent 658ad890f5
commit 32ed104b60
10 changed files with 337 additions and 153 deletions

29
util.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
"errors"
"io/fs"
"os"
"path"
"strings"
)
func Exists(p ...string) (bool, error) {
_, err := os.Stat(path.Join(p...))
if err == nil {
return true, nil
}
if errors.Is(err, fs.ErrNotExist) {
return false, nil
}
return false, err
}
func SplitExt(filename string) (string, string) {
ext := strings.ToUpper(path.Ext(filename))
name := strings.ToUpper(filename[:len(filename)-len(ext)])
if len(ext) > 0 {
ext = ext[1:]
}
return name, ext
}