Add an interface for bspatch reader
Add a wrapper class to separate the patch read from data stream
decompression. Therefore, bspatch will be able to process the patch
that is compressed with various tools.
Test: unittest pass
Change-Id: I5214e0451bde80366e8a70b960703afb2b2a7d97
diff --git a/utils.cc b/utils.cc
new file mode 100644
index 0000000..63941f5
--- /dev/null
+++ b/utils.cc
@@ -0,0 +1,20 @@
+#include <stdint.h>
+
+#include "bsdiff/utils.h"
+
+namespace bsdiff {
+
+
+int64_t ParseInt64(const uint8_t* buf) {
+ int64_t result = buf[7] & 0x7F;
+ for (int i = 6; i >= 0; i--) {
+ result <<= 8;
+ result |= buf[i];
+ }
+
+ if (buf[7] & 0x80)
+ result = -result;
+ return result;
+}
+
+} // namespace bsdiff
\ No newline at end of file