func renameXDGDirs(home, lang string) { var ( desktop = path.Join(home, "Desktop") templates = path.Join(home, "Templates") ) switch lang { case "zh_CN": if dutils.IsFileExist(desktop) { os.Rename(desktop, path.Join(home, "桌面")) } if dutils.IsFileExist(templates) { os.Rename(templates, path.Join(home, "模板")) //dutils.CreateFile(path.Join(home, "模板", "文本文件")) } case "zh_TW": if dutils.IsFileExist(desktop) { os.Rename(desktop, path.Join(home, "桌面")) } if dutils.IsFileExist(templates) { os.Rename(templates, path.Join(home, "模板")) dutils.CreateFile(path.Join(home, "模板", "新增檔案")) } default: if dutils.IsFileExist(templates) { dutils.CreateFile(path.Join(templates, "New file")) } } }
func doWriteUserConfig(config, icon, bg string, hisIcons []string) error { if !dutils.IsFileExist(config) { err := dutils.CreateFile(config) if err != nil { return err } } kFile, err := dutils.NewKeyFileFromFile(config) if err != nil { return err } defer kFile.Free() kFile.SetString("User", "Icon", icon) kFile.SetString("User", "Background", bg) kFile.SetStringList("User", "HistoryIcons", hisIcons) _, content, err := kFile.ToData() return dutils.WriteStringToFile(config, content) }