1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Implementation of the byte-level differential compression used internally by
8 #include "courgette/simple_delta.h"
10 #include "base/logging.h"
12 #include "courgette/third_party/bsdiff/bsdiff.h"
18 Status BSDiffStatusToStatus(bsdiff::BSDiffStatus status) {
20 case bsdiff::OK: return C_OK;
21 case bsdiff::CRC_ERROR: return C_BINARY_DIFF_CRC_ERROR;
22 default: return C_GENERAL_ERROR;
28 Status ApplySimpleDelta(SourceStream* old, SourceStream* delta,
30 return BSDiffStatusToStatus(bsdiff::ApplyBinaryPatch(old, delta, target));
33 Status GenerateSimpleDelta(SourceStream* old, SourceStream* target,
35 VLOG(1) << "GenerateSimpleDelta " << old->Remaining()
36 << " " << target->Remaining();
37 return BSDiffStatusToStatus(bsdiff::CreateBinaryPatch(old, target, delta));
40 } // namespace courgette