blob: 37b910d050e37bf3c5a6579acadf4911d6c77798 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Implementation of the byte-level differential compression used internally by
// Courgette.
#include "courgette/simple_delta.h"
#include "base/basictypes.h"
#include "base/logging.h"
#include "courgette/third_party/bsdiff.h"
namespace courgette {
namespace {
Status BSDiffStatusToStatus(BSDiffStatus status) {
switch (status) {
case OK: return C_OK;
case CRC_ERROR: return C_BINARY_DIFF_CRC_ERROR;
default: return C_GENERAL_ERROR;
}
}
}
Status ApplySimpleDelta(SourceStream* old, SourceStream* delta,
SinkStream* target) {
return BSDiffStatusToStatus(ApplyBinaryPatch(old, delta, target));
}
Status GenerateSimpleDelta(SourceStream* old, SourceStream* target,
SinkStream* delta) {
VLOG(1) << "GenerateSimpleDelta " << old->Remaining()
<< " " << target->Remaining();
return BSDiffStatusToStatus(CreateBinaryPatch(old, target, delta));
}
} // namespace courgette
|