33 lines
520 B
Go
33 lines
520 B
Go
package config
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/BurntSushi/toml"
|
|
)
|
|
|
|
type Ordoor struct {
|
|
DataDir string `toml:"data_dir"`
|
|
VideoPlayer []string `toml:"video_player"`
|
|
}
|
|
|
|
type Config struct {
|
|
Ordoor `toml:"ordoor"`
|
|
}
|
|
|
|
func Load(filename string) (*Config, error) {
|
|
var out Config
|
|
|
|
_, err := toml.DecodeFile(filename, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &out, err
|
|
}
|
|
|
|
// TODO: case-insensitive lookup
|
|
func (c *Config) DataFile(path string) string {
|
|
return filepath.Join(c.DataDir, path)
|
|
}
|