示例#1
0
文件: uptoshare.go 项目: sqp/godock
func (up *Uploader) saveHistory() {
	if _, e := os.Stat(filepath.Dir(up.historyFile)); e != nil {
		os.Mkdir(filepath.Dir(up.historyFile), os.ModePerm)
	}

	cfg := config.NewEmpty(up.Log, up.historyFile)
	defer cfg.Save()
	for _, hist := range up.ListHistory() {
		group := hist["link"]
		for key, link := range hist {
			cfg.Set(group, key, link)
		}
	}
}
示例#2
0
文件: maindock.go 项目: sqp/godock
// loadHidden will try to load the hidden config data from the file.
//
func loadHidden(path string) *hiddenConfig {
	file := filepath.Join(path, cdglobal.FileHiddenConfig)
	hidden := &hiddenConfig{}

	// Load data from file.
	e := config.GetFromFile(log, file, func(cfg cdtype.ConfUpdater) {
		cfg.UnmarshalGroup(hidden, hiddenGroup, config.GetTag)
	})

	if e != nil { // File missing, create it.
		conf := config.NewEmpty(log, file)

		conf.MarshalGroup(hidden, hiddenGroup, config.GetTag)
		conf.Set("Gui", "mode", "0") // another section unused here.

		e = conf.Save()
		log.Err(e, "create hidden conf", file)
	}

	return hidden
}