From 15fe28c9af4a69d5fb5188c3cbeadae31a9c891f Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 25 Jul 2017 23:32:10 +0200 Subject: prototype gzip verify --- file/file.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'file/file.go') 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) -- cgit v1.2.3