summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorIvan Daniluk <ivan.daniluk@gmail.com>2014-04-12 12:32:59 +0200
committerIvan Daniluk <ivan.daniluk@gmail.com>2014-04-12 12:32:59 +0200
commit052cc0ab58874c89ad15e32fcbccd2212cd71c7b (patch)
treea279e999f32319f54eefa714b3e4ad7e12d59a80 /util.go
parent1e8f9e3d345377d69d0ca13bd65dfa15503b5a12 (diff)
Added possibility to register images via custom Reader.
Diffstat (limited to 'util.go')
-rw-r--r--util.go13
1 files changed, 4 insertions, 9 deletions
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
}