-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
80 lines (72 loc) 路 1.75 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//go:generate go install -v github.com/josephspurrier/goversioninfo/cmd/goversioninfo
//go:generate goversioninfo -icon=res/papp.ico -manifest=res/papp.manifest
package main
import (
"os"
"github.com/go-ini/ini"
"github.com/portapps/portapps/v3"
"github.com/portapps/portapps/v3/pkg/log"
"github.com/portapps/portapps/v3/pkg/utl"
)
var (
app *portapps.App
)
func init() {
var err error
// Init app
if app, err = portapps.New("mirc-portable", "mIRC"); err != nil {
log.Fatal().Err(err).Msg("Cannot initialize application. See log file for more info.")
}
}
func main() {
utl.CreateFolder(app.DataPath)
app.Process = utl.PathJoin(app.AppPath, "mirc.exe")
app.Args = []string{
"-r" + app.DataPath,
"-noreg",
}
// Update settings
settingsPath := utl.PathJoin(app.DataPath, "mirc.ini")
if _, err := os.Stat(settingsPath); err == nil {
ini.PrettyFormat = false
log.Info().Msg("Update settings...")
cfg, err := ini.LoadSources(ini.LoadOptions{
IgnoreInlineComment: true,
SkipUnrecognizableLines: false,
UnescapeValueDoubleQuotes: true,
UnescapeValueCommentSymbols: true,
PreserveSurroundedQuote: true,
SpaceBeforeInlineComment: true,
UnparseableSections: []string{
"chanfolder",
"dirs",
"colors",
"extensions",
"ssl",
"about",
"afiles",
"options",
"pfiles",
"rfiles",
"user",
"agent",
"windows",
"text",
"files",
"mirc",
"dde",
"ports",
},
}, settingsPath)
if err == nil {
cfg.Section("update").Key("check").SetValue("0")
if err := cfg.SaveTo(settingsPath); err != nil {
log.Error().Err(err).Msg("Write settings")
}
} else {
log.Error().Err(err).Msg("Load mirc.ini file")
}
}
defer app.Close()
app.Launch(os.Args[1:])
}