Fix filepath separator and external files on windows

For some reason, '/' is used instead of '\' on windows when loading
lang. FSJoin will now use whatever already exists in the path.
app.GetPath now creates a DirFS from the containing directory instead of
app.systemFS, which fixes loading on windows.
This commit is contained in:
Harvey Tindall
2021-02-18 12:58:30 +00:00
parent cdc837e781
commit adbb5b9d38
5 changed files with 21 additions and 8 deletions
+3 -1
View File
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"io/fs"
"os"
"path/filepath"
"strconv"
"strings"
@@ -17,7 +18,8 @@ func (app *appContext) GetPath(sect, key string) (fs.FS, string) {
if strings.HasPrefix(val, "jfa-go:") {
return localFS, strings.TrimPrefix(val, "jfa-go:")
}
return app.systemFS, strings.TrimPrefix(val, "/")
dir, file := filepath.Split(val)
return os.DirFS(dir), file
}
func (app *appContext) loadConfig() error {