summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSen Jiang <senj@google.com>2017-02-16 21:23:18 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-02-16 21:23:18 +0000
commit492cede2b6d103bc32ac726e166f1e40bba62397 (patch)
tree15cf0bcb6eab21a76302345d79d80e5c8caf4c09
parent59ac7b2e8e6e591c1807c60cf5d24b643896ff38 (diff)
parent9e29277587ccc2384c2fe36db7cb93b4be1917ea (diff)
downloadbsdiff-492cede2b6d103bc32ac726e166f1e40bba62397.tar.gz
Add another overload of bspatch(). am: 62d5e48122
am: 9e29277587 Change-Id: Ia9a0c13eece722dacf04cc7040029e835b2677d6
-rw-r--r--bspatch.cc18
-rw-r--r--bspatch.h7
2 files changed, 23 insertions, 2 deletions
diff --git a/bspatch.cc b/bspatch.cc
index 0d90676..058f9d0 100644
--- a/bspatch.cc
+++ b/bspatch.cc
@@ -201,6 +201,20 @@ int bspatch(const char* old_filename,
}
patch_file.reset();
+ return bspatch(old_filename, new_filename, patch.data(), patch_size,
+ old_extents, new_extents);
+}
+
+// Patch |old_filename| with |patch_data| and save it to |new_filename|.
+// |old_extents| and |new_extents| are comma-separated lists of "offset:length"
+// extents of |old_filename| and |new_filename|.
+// Returns 0 on success, 1 on I/O error and 2 on data error.
+int bspatch(const char* old_filename,
+ const char* new_filename,
+ const uint8_t* patch_data,
+ size_t patch_size,
+ const char* old_extents,
+ const char* new_extents) {
int using_extents = (old_extents != NULL || new_extents != NULL);
// Open input file for reading.
@@ -242,11 +256,11 @@ int bspatch(const char* old_filename,
parsed_new_extents)) {
// New and old file is overlapping, we can not stream output to new file,
// cache it in a buffer and write to the file at the end.
- uint64_t newsize = ParseInt64(patch.data() + 24);
+ uint64_t newsize = ParseInt64(patch_data + 24);
new_file.reset(new BufferFile(std::move(new_file), newsize));
}
- return bspatch(old_file, new_file, patch.data(), patch_size);
+ return bspatch(old_file, new_file, patch_data, patch_size);
}
// Patch |old_data| with |patch_data| and save it by calling sink function.
diff --git a/bspatch.h b/bspatch.h
index 2507879..834715b 100644
--- a/bspatch.h
+++ b/bspatch.h
@@ -19,6 +19,13 @@ int bspatch(const char* old_filename,
const char* old_extents,
const char* new_extents);
+int bspatch(const char* old_filename,
+ const char* new_filename,
+ const uint8_t* patch_data,
+ size_t patch_size,
+ const char* old_extents,
+ const char* new_extents);
+
int bspatch(const uint8_t* old_data,
size_t old_size,
const uint8_t* patch_data,