gofmt.
This commit is contained in:
@@ -10,85 +10,85 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
// stdlib
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
// stdlib
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
// Configuration from database.
|
||||
Cfg map[string]string
|
||||
// Temporary (or runtime) configuration things.
|
||||
TEMP map[string]string
|
||||
// Configuration from database.
|
||||
Cfg map[string]string
|
||||
// Temporary (or runtime) configuration things.
|
||||
TEMP map[string]string
|
||||
}
|
||||
|
||||
func (c *Config) initializePathsMac() {
|
||||
fmt.Println("Initializing configuration paths...")
|
||||
home_path := os.Getenv("HOME")
|
||||
data_path := path.Join(home_path, "Library", "Application Support", "URTrator")
|
||||
fmt.Println("Will use data path: " + data_path)
|
||||
c.TEMP["DATA"] = data_path
|
||||
fmt.Println("Initializing configuration paths...")
|
||||
home_path := os.Getenv("HOME")
|
||||
data_path := path.Join(home_path, "Library", "Application Support", "URTrator")
|
||||
fmt.Println("Will use data path: " + data_path)
|
||||
c.TEMP["DATA"] = data_path
|
||||
|
||||
profile_path := path.Join(home_path, "Library", "Application Support", "Quake3", "q3ut4")
|
||||
c.TEMP["DEFAULT_PROFILE_PATH"] = profile_path
|
||||
profile_path := path.Join(home_path, "Library", "Application Support", "Quake3", "q3ut4")
|
||||
c.TEMP["DEFAULT_PROFILE_PATH"] = profile_path
|
||||
|
||||
if _, err := os.Stat(data_path); os.IsNotExist(err) {
|
||||
os.MkdirAll(data_path, 0755)
|
||||
}
|
||||
if _, err := os.Stat(data_path); os.IsNotExist(err) {
|
||||
os.MkdirAll(data_path, 0755)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) initializePathsNix() {
|
||||
fmt.Println("Initializing configuration paths...")
|
||||
fmt.Println("Initializing configuration paths...")
|
||||
|
||||
// Get storage path. By default we will use ~/.config/urtrator
|
||||
// directory.
|
||||
home_path := os.Getenv("HOME")
|
||||
data_path := path.Join(home_path, ".config", "urtrator")
|
||||
fmt.Println("Will use data path: " + data_path)
|
||||
c.TEMP["DATA"] = data_path
|
||||
// Get storage path. By default we will use ~/.config/urtrator
|
||||
// directory.
|
||||
home_path := os.Getenv("HOME")
|
||||
data_path := path.Join(home_path, ".config", "urtrator")
|
||||
fmt.Println("Will use data path: " + data_path)
|
||||
c.TEMP["DATA"] = data_path
|
||||
|
||||
profile_path := path.Join(home_path, ".q3a", "q3ut4")
|
||||
c.TEMP["DEFAULT_PROFILE_PATH"] = profile_path
|
||||
profile_path := path.Join(home_path, ".q3a", "q3ut4")
|
||||
c.TEMP["DEFAULT_PROFILE_PATH"] = profile_path
|
||||
|
||||
if _, err := os.Stat(data_path); os.IsNotExist(err) {
|
||||
os.MkdirAll(data_path, 0755)
|
||||
}
|
||||
if _, err := os.Stat(data_path); os.IsNotExist(err) {
|
||||
os.MkdirAll(data_path, 0755)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) initializePathsWin() {
|
||||
fmt.Println("Initializing configuration paths...")
|
||||
homepath_without_drive := os.Getenv("HOMEPATH")
|
||||
homedrive := os.Getenv("HOMEDRIVE")
|
||||
data_path := path.Join(homedrive, homepath_without_drive, "AppData", "Roaming", "URTrator")
|
||||
c.TEMP["DATA"] = data_path
|
||||
fmt.Println("Initializing configuration paths...")
|
||||
homepath_without_drive := os.Getenv("HOMEPATH")
|
||||
homedrive := os.Getenv("HOMEDRIVE")
|
||||
data_path := path.Join(homedrive, homepath_without_drive, "AppData", "Roaming", "URTrator")
|
||||
c.TEMP["DATA"] = data_path
|
||||
|
||||
// Verify it!
|
||||
profile_path := path.Join(homedrive, homepath_without_drive, "AppData", "UrbanTerror43", "q3ut4")
|
||||
c.TEMP["DEFAULT_PROFILE_PATH"] = profile_path
|
||||
// Verify it!
|
||||
profile_path := path.Join(homedrive, homepath_without_drive, "AppData", "UrbanTerror43", "q3ut4")
|
||||
c.TEMP["DEFAULT_PROFILE_PATH"] = profile_path
|
||||
|
||||
if _, err := os.Stat(data_path); os.IsNotExist(err) {
|
||||
os.MkdirAll(data_path, 0755)
|
||||
}
|
||||
if _, err := os.Stat(data_path); os.IsNotExist(err) {
|
||||
os.MkdirAll(data_path, 0755)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) initializeStorages() {
|
||||
c.TEMP = make(map[string]string)
|
||||
c.Cfg = make(map[string]string)
|
||||
c.TEMP = make(map[string]string)
|
||||
c.Cfg = make(map[string]string)
|
||||
}
|
||||
|
||||
func (c *Config) Initialize() {
|
||||
fmt.Println("Initializing configuration storage...")
|
||||
c.initializeStorages()
|
||||
fmt.Println("Initializing configuration storage...")
|
||||
c.initializeStorages()
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
c.initializePathsNix()
|
||||
} else if runtime.GOOS == "darwin" {
|
||||
c.initializePathsMac()
|
||||
} else if runtime.GOOS == "windows" {
|
||||
c.initializePathsWin()
|
||||
} else {
|
||||
panic("We're not ready for other OSes yet!")
|
||||
}
|
||||
if runtime.GOOS == "linux" {
|
||||
c.initializePathsNix()
|
||||
} else if runtime.GOOS == "darwin" {
|
||||
c.initializePathsMac()
|
||||
} else if runtime.GOOS == "windows" {
|
||||
c.initializePathsWin()
|
||||
} else {
|
||||
panic("We're not ready for other OSes yet!")
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,6 @@
|
||||
package configuration
|
||||
|
||||
func New() *Config {
|
||||
c := Config{}
|
||||
return &c
|
||||
c := Config{}
|
||||
return &c
|
||||
}
|
||||
|
Reference in New Issue
Block a user