more (untested) windows bugfixes

This commit is contained in:
Al Beano 2017-05-30 18:54:52 +01:00
parent 94fc08b2b1
commit 80a07f768d
3 changed files with 24 additions and 1 deletions

View File

@ -2,7 +2,16 @@
package platform package platform
import(
"path"
)
func SanitiseFilename(filename string) (newName string, e error) { func SanitiseFilename(filename string) (newName string, e error) {
newName = filename newName = filename
return return
} }
func DirOf(filename string) (dirname string, e error) {
dirname = path.Dir(filename)
return
}

View File

@ -15,3 +15,13 @@ func SanitiseFilename(filename string) (newName string, e error) {
newName = r.ReplaceAllString(filename, "") newName = r.ReplaceAllString(filename, "")
return return
} }
func DirOf(filename string) (dirname string, e error) {
r, e := regexp.Compile(`[^\ ]+$`)
if e != nil {
return
}
dirname = r.ReplaceAllString(filename, "")
return
}

View File

@ -30,7 +30,11 @@ func main() {
} }
exe, _ := os.Executable() exe, _ := os.Executable()
wDir := path.Dir(exe) wDir, e := platform.DirOf(exe)
if e != nil {
panic(e)
}
magicData, e := ioutil.ReadFile(wDir + "/magic.json") magicData, e := ioutil.ReadFile(wDir + "/magic.json")
if e != nil { if e != nil {
panic(e) panic(e)