1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-11-05 01:40:10 +00:00
jfa-go/external.go

38 lines
756 B
Go
Raw Normal View History

// +build external
2021-02-17 14:32:03 +00:00
package main
import (
"io/fs"
"log"
"os"
"path/filepath"
"strings"
2021-02-17 14:32:03 +00:00
)
const binaryType = "external"
2021-02-17 14:32:03 +00:00
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)
}
2021-02-17 14:32:03 +00:00
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"))
}