mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-14 06:10:10 +00:00
Harvey Tindall
adbb5b9d38
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.
34 lines
705 B
Go
34 lines
705 B
Go
package main
|
|
|
|
import (
|
|
"io/fs"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
var localFS fs.FS
|
|
var langFS fs.FS
|
|
|
|
// When using os.DirFS, even on Windows the separator seems to be '/'.
|
|
// func FSJoin(elem ...string) string { return filepath.Join(elem...) }
|
|
func FSJoin(elem ...string) string {
|
|
sep := "/"
|
|
if strings.Contains(elem[0], "\\") {
|
|
sep = "\\"
|
|
}
|
|
path := ""
|
|
for _, el := range elem {
|
|
path += el + sep
|
|
}
|
|
return strings.TrimSuffix(path, sep)
|
|
}
|
|
|
|
func loadFilesystems() {
|
|
log.Println("Using external storage")
|
|
executable, _ := os.Executable()
|
|
localFS = os.DirFS(filepath.Join(filepath.Dir(executable), "data"))
|
|
langFS = os.DirFS(filepath.Join(filepath.Dir(executable), "data", "lang"))
|
|
}
|