Add LoadFile

This commit is contained in:
Thomas Pelletier
2013-03-22 17:14:16 +01:00
parent 0d489ff32c
commit 21a8fb6ee0
2 changed files with 33 additions and 2 deletions
+14
View File
@@ -6,6 +6,7 @@ package toml
import (
"errors"
"io/ioutil"
"runtime"
"strings"
)
@@ -89,3 +90,16 @@ func Load(content string) (tree *TomlTree, err error) {
tree = parse(flow)
return
}
// Create a TomlTree from a file.
func LoadFile(path string) (tree *TomlTree, err error) {
buff, ferr := ioutil.ReadFile(path)
if (ferr != nil) {
err = ferr
} else {
s := string(buff)
tree, err = Load(s)
}
return
}