mirror of https://github.com/hrfee/jfa-go
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
756 B
38 lines
756 B
4 years ago
|
// +build external
|
||
|
|
||
4 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"io/fs"
|
||
|
"log"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
4 years ago
|
"strings"
|
||
4 years ago
|
)
|
||
|
|
||
4 years ago
|
const binaryType = "external"
|
||
|
|
||
4 years ago
|
var localFS fs.FS
|
||
|
var langFS fs.FS
|
||
|
|
||
4 years ago
|
// 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)
|
||
|
}
|
||
4 years ago
|
|
||
|
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"))
|
||
|
}
|