add wkfs.ReadFile, use it in serverinit

Change-Id: I2870568e41de9ddb879c51606c77aec0ec77c4ef
This commit is contained in:
Brad Fitzpatrick 2014-08-05 12:51:17 -07:00
parent 5540a38dbd
commit 966d25cb62
2 changed files with 12 additions and 2 deletions

View File

@ -26,7 +26,6 @@ import (
"expvar"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/pprof"
@ -44,6 +43,7 @@ import (
"camlistore.org/pkg/jsonconfig"
"camlistore.org/pkg/server/app"
"camlistore.org/pkg/types/serverconfig"
"camlistore.org/pkg/wkfs"
)
const camliPrefix = "/camli/"
@ -466,7 +466,7 @@ func load(filename string, rootConfig []byte, opener func(filename string) (json
}
if rootConfig == nil {
rootConfig, err = ioutil.ReadFile(filename)
rootConfig, err = wkfs.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("Could not read %s: %v", filename, err)
}

View File

@ -29,6 +29,7 @@ package wkfs
import (
"io"
"io/ioutil"
"os"
"strings"
)
@ -118,3 +119,12 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error {
}
return err
}
func ReadFile(filename string) ([]byte, error) {
f, err := Open(filename)
if err != nil {
return nil, err
}
defer f.Close()
return ioutil.ReadAll(f)
}