Add functionality to read the configuration from file.
[armadillo.git] / src / config.go
1 //
2 // Armadillo File Manager
3 // Copyright (c) 2010, Robert Sesek <http://www.bluestatic.org>
4 //
5 // This program is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free Software
7 // Foundation, either version 3 of the License, or any later version.
8 //
9
10 package config
11
12 import (
13 "json"
14 "os"
15 )
16
17 type Configuration struct {
18 JailRoot string
19 Port int
20 ProxyURLs []string
21 Users map [string] string
22 }
23
24 func ReadFromFile(aPath string, config *Configuration) os.Error {
25 fd, error := os.Open(aPath, os.O_RDONLY, 0)
26 if error != nil {
27 return error
28 }
29 decoder := json.NewDecoder(fd)
30 return decoder.Decode(config)
31 }