use full path for android to cwtch dir

This commit is contained in:
Dan Ballard 2019-02-19 13:32:52 -08:00
parent 3a25e79916
commit 0653430164
1 changed files with 6 additions and 4 deletions

10
main.go
View File

@ -22,6 +22,8 @@ import (
"fmt"
)
const androidBaseDir = "/data/data/org.qtproject.example.go/"
func init() {
// make go-defined types available in qml
gothings.GrandCentralDispatcher_QmlRegisterType2("CustomQmlTypes", 1, 0, "GrandCentralDispatcher")
@ -35,7 +37,6 @@ func main() {
log.SetLevel(log.LevelInfo)
}
// our globals
gcd := gothings.NewGrandCentralDispatcher(nil)
gcd.UIState = gothings.NewUIState(gcd)
@ -53,7 +54,6 @@ func main() {
qmlSource = core.NewQUrl3("qrc:/qml/main.qml", 0)
}
app := gui.NewQGuiApplication(len(os.Args), os.Args)
app.SetWindowIcon(gui.NewQIcon5(":/qml/images/cwtch-icon.png"))
@ -72,7 +72,9 @@ func main() {
if os.Getenv("CWTCH_FOLDER") != "" {
the.CwtchDir = os.Getenv("CWTCH_FOLDER")
} else {
} else if runtime.GOOS == "android" {
the.CwtchDir = path.Join(androidBaseDir, "files")
} else {
usr, err := user.Current()
if err != nil {
fmt.Printf("\nerror: could not load current user: %v\n", err)
@ -83,7 +85,7 @@ func main() {
torpath := "tor"
if runtime.GOOS == "android" {
torpath = "/data/data/org.qtproject.example.go/lib/libtor.so"
torpath = path.Join(androidBaseDir, "lib/libtor.so")
} else {
dir, _ := filepath.Abs(filepath.Dir(os.Args[0]))
if _, err := os.Stat(path.Join(dir, "tor")); os.IsNotExist(err) {