• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium OS 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.
4 
5 #ifndef SRC_INCLUDE_PUFFIN_PUFFDIFF_H_
6 #define SRC_INCLUDE_PUFFIN_PUFFDIFF_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "puffin/common.h"
12 #include "puffin/stream.h"
13 
14 namespace puffin {
15 
16 // Performs a diff operation between input deflate streams and creates a patch
17 // that is used in the client to recreate the |dst| from |src|.
18 // |src|          IN   Source deflate stream.
19 // |dst|          IN   Destination deflate stream.
20 // |src_deflates| IN   Deflate locations in |src|.
21 // |dst_deflates| IN   Deflate locations in |dst|.
22 // |tmp_filepath| IN   A path to a temporary file. The caller has the
23 //                     responsibility of unlinking the file after the call to
24 //                     |PuffDiff| finishes.
25 // |puffin_patch| OUT  The patch that later can be used in |PuffPatch|.
26 bool PuffDiff(UniqueStreamPtr src,
27               UniqueStreamPtr dst,
28               const std::vector<BitExtent>& src_deflates,
29               const std::vector<BitExtent>& dst_deflates,
30               const std::string& tmp_filepath,
31               Buffer* patch);
32 
33 // Similar to the function above, except that it accepts raw buffer rather than
34 // stream.
35 PUFFIN_EXPORT
36 bool PuffDiff(const Buffer& src,
37               const Buffer& dst,
38               const std::vector<BitExtent>& src_deflates,
39               const std::vector<BitExtent>& dst_deflates,
40               const std::string& tmp_filepath,
41               Buffer* patch);
42 
43 }  // namespace puffin
44 
45 #endif  // SRC_INCLUDE_PUFFIN_PUFFDIFF_H_
46