From 966d25cb62ba089faff5b8dac944273df3c6457d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 5 Aug 2014 12:51:17 -0700 Subject: [PATCH] add wkfs.ReadFile, use it in serverinit Change-Id: I2870568e41de9ddb879c51606c77aec0ec77c4ef --- pkg/serverinit/serverinit.go | 4 ++-- pkg/wkfs/wkfs.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/serverinit/serverinit.go b/pkg/serverinit/serverinit.go index c88722874..0cd472bc4 100644 --- a/pkg/serverinit/serverinit.go +++ b/pkg/serverinit/serverinit.go @@ -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) } diff --git a/pkg/wkfs/wkfs.go b/pkg/wkfs/wkfs.go index d670dc7f8..65235fbac 100644 --- a/pkg/wkfs/wkfs.go +++ b/pkg/wkfs/wkfs.go @@ -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) +}