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.

47 lines
845 B

4 years ago
package main
import (
"encoding/json"
"io/ioutil"
)
/*
Game chess.Game
StartTime time.Time
ConvID string
White string
Black string
Move bool
*/
func loadConfig() Config {
4 years ago
var c Config
confFile, _ := ioutil.ReadFile(configFile)
_ = json.Unmarshal([]byte(confFile), &c)
for cid, game := range c.Games {
g := game.Game.Clone()
c.Games[cid] = Game{
Game: *g,
StartTime: game.StartTime,
ConvID: game.ConvID,
White: game.White,
Black: game.Black,
Move: game.Move,
}
}
return c
4 years ago
}
func saveConfig() {
4 years ago
defer log.PanicSafe("saveConfig")
log.LogInfo("Saving config.")
4 years ago
file, err := json.Marshal(config)
if err != nil {
log.LogErrorType(err)
}
err = ioutil.WriteFile(configFile, file, 0600)
if err != nil {
log.LogErrorType(err)
}
log.LogInfo("Config Saved.")
4 years ago
}