From 052cc0ab58874c89ad15e32fcbccd2212cd71c7b Mon Sep 17 00:00:00 2001 From: Ivan Daniluk Date: Sat, 12 Apr 2014 12:32:59 +0200 Subject: Added possibility to register images via custom Reader. --- util.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'util.go') diff --git a/util.go b/util.go index b07a37d..96ffd9b 100644 --- a/util.go +++ b/util.go @@ -21,6 +21,7 @@ import ( "compress/zlib" "fmt" // "github.com/davecgh/go-spew/spew" + "io" "math" "os" ) @@ -58,16 +59,10 @@ func fileSize(filename string) (size int64, ok bool) { return } -// Returns a new buffer populated with the contents of the specified file -func bufferFromFile(fileStr string) (b *bytes.Buffer, err error) { - var fl *os.File - fl, err = os.Open(fileStr) - if err != nil { - return - } - defer fl.Close() +// Returns a new buffer populated with the contents of the specified Reader +func bufferFromReader(r io.Reader) (b *bytes.Buffer, err error) { b = new(bytes.Buffer) - _, err = b.ReadFrom(fl) + _, err = b.ReadFrom(r) return } -- cgit v1.2.1-24-ge1ad