diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-27 09:35:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 09:35:19 +0200 |
commit | 854ffa16f650706200a6ebb5505bb448b5c64035 (patch) | |
tree | 61892f335f61c6fbb2bf65f7daf51829276a8e28 /utils | |
parent | c2561364e33763d3356a23c5850424a334de30e9 (diff) | |
parent | 48900a1c810dd2dac9cb44511e6a2412d3064da6 (diff) | |
download | go-git-854ffa16f650706200a6ebb5505bb448b5c64035.tar.gz |
Merge pull request #512 from mcuadros/idx-64bits
format: idxfile, support for >2Gb packfiles
Diffstat (limited to 'utils')
-rw-r--r-- | utils/binary/read.go | 12 | ||||
-rw-r--r-- | utils/binary/write.go | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/utils/binary/read.go b/utils/binary/read.go index c256ffe..50da1ff 100644 --- a/utils/binary/read.go +++ b/utils/binary/read.go @@ -94,7 +94,17 @@ const ( lengthBits = uint8(7) // subsequent bytes has 7 bits to store the length ) -// ReadUint32 reads 4 bytes and returns them as a Big ndian uint32 +// ReadUint64 reads 8 bytes and returns them as a BigEndian uint32 +func ReadUint64(r io.Reader) (uint64, error) { + var v uint64 + if err := binary.Read(r, binary.BigEndian, &v); err != nil { + return 0, err + } + + return v, nil +} + +// ReadUint32 reads 4 bytes and returns them as a BigEndian uint32 func ReadUint32(r io.Reader) (uint32, error) { var v uint32 if err := binary.Read(r, binary.BigEndian, &v); err != nil { diff --git a/utils/binary/write.go b/utils/binary/write.go index 2ec3581..c08c73a 100644 --- a/utils/binary/write.go +++ b/utils/binary/write.go @@ -31,6 +31,12 @@ func WriteVariableWidthInt(w io.Writer, n int64) error { return err } +// WriteUint64 writes the binary representation of a uint64 into w, in BigEndian +// order +func WriteUint64(w io.Writer, value uint64) error { + return binary.Write(w, binary.BigEndian, value) +} + // WriteUint32 writes the binary representation of a uint32 into w, in BigEndian // order func WriteUint32(w io.Writer, value uint32) error { |