aboutsummaryrefslogtreecommitdiff
path: root/file/file.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-07-25 23:32:10 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-07-25 23:32:10 +0200
commit15fe28c9af4a69d5fb5188c3cbeadae31a9c891f (patch)
tree89f665b0dd71fbe4db17f598bdb494924a774290 /file/file.go
parente718cddb32df846caea3a1235a3dc806e03dc1e4 (diff)
prototype gzip verify
Diffstat (limited to 'file/file.go')
-rw-r--r--file/file.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/file/file.go b/file/file.go
index e954604..5b3fbcf 100644
--- a/file/file.go
+++ b/file/file.go
@@ -3,6 +3,7 @@ package file
import (
"bufio"
+ "bytes"
"encoding"
"encoding/base64"
"errors"
@@ -20,7 +21,8 @@ const (
untrusted = "untrusted comment:"
)
-var ErrComment = errors.New("expected untrusted comment")
+// Original Error: "invalid comment in %s; must start with 'untrusted comment: '"
+var ErrComment = errors.New("comment must start with 'untrusted comment: '")
func DecodeFile(fname string, u encoding.BinaryUnmarshaler) (string, []byte, error) {
fd, err := os.Open(fname)
@@ -31,6 +33,16 @@ func DecodeFile(fname string, u encoding.BinaryUnmarshaler) (string, []byte, err
return Decode(fd, u)
}
+func DecodeString(data string, u encoding.BinaryUnmarshaler) (string, []byte, error) {
+ r := strings.NewReader(data)
+ return Decode(r, u)
+}
+
+func DecodeBytes(data []byte, u encoding.BinaryUnmarshaler) (string, []byte, error) {
+ r := bytes.NewReader(data)
+ return Decode(r, u)
+}
+
func Decode(r io.Reader, u encoding.BinaryUnmarshaler) (string, []byte, error) {
buf := bufio.NewReader(r)