From 584fa1d4f6bcc7e0c769e0dbfa36f819a93f3ec2 Mon Sep 17 00:00:00 2001 From: "rahulk@google.com" Date: Mon, 8 Sep 2008 17:40:14 +0000 Subject: Fix binary patching for localized OS. Not sure how it was working till now. BUG=1557 Review URL: http://codereview.chromium.org/268 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1848 0039d316-1c4b-4281-b951-d872f2087c98 --- third_party/bspatch/README.google | 3 +++ third_party/bspatch/mbspatch.cc | 10 +++++----- third_party/bspatch/mbspatch.h | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'third_party/bspatch') diff --git a/third_party/bspatch/README.google b/third_party/bspatch/README.google index 9f26265..3c6f8685 100644 --- a/third_party/bspatch/README.google +++ b/third_party/bspatch/README.google @@ -8,3 +8,6 @@ http://lxr.mozilla.org/mozilla/source/toolkit/mozapps/update/src/updater/ The license is shared in common with bsdiff. Local changes include CRC32 verification. + +Update(08 Sep 08): Changed ApplyBinaryPatch to accept wchar_t paths +instead of char paths. \ No newline at end of file diff --git a/third_party/bspatch/mbspatch.cc b/third_party/bspatch/mbspatch.cc index 87d7895..f67aa11 100644 --- a/third_party/bspatch/mbspatch.cc +++ b/third_party/bspatch/mbspatch.cc @@ -209,16 +209,16 @@ int CalculateCrc(const unsigned char *buf, int size) { # define _O_BINARY 0 #endif -int ApplyBinaryPatch(const char *old_file, const char *patch_file, - const char *new_file) { +int ApplyBinaryPatch(const wchar_t *old_file, const wchar_t *patch_file, + const wchar_t *new_file) { int ret = 0; - int pfd = open(patch_file, O_RDONLY | _O_BINARY); + int pfd = _wopen(patch_file, O_RDONLY | _O_BINARY); if (pfd < 0) return READ_ERROR; MBSPatchHeader header; if (ret = MBS_ReadHeader(pfd, &header)) return ret; - int ofd = open(old_file, O_RDONLY | _O_BINARY); + int ofd = _wopen(old_file, O_RDONLY | _O_BINARY); if (ofd < 0) return READ_ERROR; struct stat os; @@ -232,7 +232,7 @@ int ApplyBinaryPatch(const char *old_file, const char *patch_file, if (CalculateCrc(buf, header.slen) != header.scrc32) return CRC_ERROR; - int nfd = open(new_file, O_WRONLY | O_TRUNC | O_CREAT | _O_BINARY); + int nfd = _wopen(new_file, O_WRONLY | O_TRUNC | O_CREAT | _O_BINARY); if (nfd < 0) return READ_ERROR; MBS_ApplyPatch(&header, pfd, buf, nfd); diff --git a/third_party/bspatch/mbspatch.h b/third_party/bspatch/mbspatch.h index 9e5123b..1a901d7 100644 --- a/third_party/bspatch/mbspatch.h +++ b/third_party/bspatch/mbspatch.h @@ -102,8 +102,8 @@ typedef struct MBSPatchTriple_ { * the CRC of the original file stored in the patch file, before applying the * patch to it. */ -int ApplyBinaryPatch(const char *old_file, const char *patch_file, - const char *new_file); +int ApplyBinaryPatch(const wchar_t *old_file, const wchar_t *patch_file, + const wchar_t *new_file); /** * Calculates Crc of the given buffer by calling CRC method in LZMA SDK -- cgit v1.1