1 // SPDX-License-Identifier: Unlicense OR MIT
2 3 package app
4 5 import (
6 "os"
7 "strings"
8 9 "github.com/p9c/p9/pkg/gel/gio/app/internal/wm"
10 )
11 12 // extraArgs contains extra arguments to append to
13 // os.Args. The arguments are separated with |.
14 // Useful for running programs on mobiles where the
15 // command line is not available.
16 // Set with the go linker flag -X.
17 var extraArgs string
18 19 func init() {
20 if extraArgs != "" {
21 args := strings.Split(extraArgs, "|")
22 os.Args = append(os.Args, args...)
23 }
24 }
25 26 // DataDir returns a path to use for application-specific
27 // configuration data.
28 // On desktop systems, DataDir use os.UserConfigDir.
29 // On iOS NSDocumentDirectory is queried.
30 // For Android Context.getFilesDir is used.
31 //
32 // BUG: DataDir blocks on Android until init functions
33 // have completed.
34 func DataDir() (string, error) {
35 return dataDir()
36 }
37 38 // Main must be called last from the program main function.
39 // On most platforms Main blocks forever, for Android and
40 // iOS it returns immediately to give control of the main
41 // thread back to the system.
42 //
43 // Calling Main is necessary because some operating systems
44 // require control of the main thread of the program for
45 // running windows.
46 func Main() {
47 wm.Main()
48 }
49