• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 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 _BSDIFF_BSPATCH_H_
6 #define _BSDIFF_BSPATCH_H_
7 
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 #include <functional>
12 #include <memory>
13 #include <vector>
14 
15 #include "bsdiff/extents_file.h"
16 
17 namespace bsdiff {
18 
19 BSDIFF_EXPORT
20 int bspatch(const char* old_filename,
21             const char* new_filename,
22             const char* patch_filename,
23             const char* old_extents,
24             const char* new_extents);
25 
26 BSDIFF_EXPORT
27 int bspatch(const char* old_filename,
28             const char* new_filename,
29             const uint8_t* patch_data,
30             size_t patch_size,
31             const char* old_extents,
32             const char* new_extents);
33 
34 BSDIFF_EXPORT
35 int bspatch(const uint8_t* old_data,
36             size_t old_size,
37             const uint8_t* patch_data,
38             size_t patch_size,
39             const std::function<size_t(const uint8_t*, size_t)>& sink);
40 
41 BSDIFF_EXPORT
42 int bspatch(const std::unique_ptr<FileInterface>& old_file,
43             const std::unique_ptr<FileInterface>& new_file,
44             const uint8_t* patch_data,
45             size_t patch_size);
46 
47 bool WriteAll(const std::unique_ptr<FileInterface>& file,
48               const uint8_t* data,
49               size_t size);
50 
51 bool IsOverlapping(const char* old_filename,
52                    const char* new_filename,
53                    const std::vector<ex_t>& old_extents,
54                    const std::vector<ex_t>& new_extents);
55 
56 }  // namespace bsdiff
57 
58 #endif  // _BSDIFF_BSPATCH_H_
59