OLD | NEW |
1 /*- | 1 /*- |
2 * Copyright 2003,2004 Colin Percival | 2 * Copyright 2003,2004 Colin Percival |
3 * All rights reserved | 3 * All rights reserved |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted providing that the following conditions | 6 * modification, are permitted providing that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 24 matching lines...) Expand all Loading... |
35 */ | 35 */ |
36 | 36 |
37 #ifndef COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ | 37 #ifndef COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ |
38 #define COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ | 38 #define COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ |
39 | 39 |
40 #include <stdint.h> | 40 #include <stdint.h> |
41 | 41 |
42 #include "base/files/file_util.h" | 42 #include "base/files/file_util.h" |
43 | 43 |
44 namespace courgette { | 44 namespace courgette { |
| 45 class SourceStream; |
| 46 class SinkStream; |
| 47 } // namespace courgette |
| 48 |
| 49 namespace bsdiff { |
45 | 50 |
46 enum BSDiffStatus { | 51 enum BSDiffStatus { |
47 OK = 0, | 52 OK = 0, |
48 MEM_ERROR = 1, | 53 MEM_ERROR = 1, |
49 CRC_ERROR = 2, | 54 CRC_ERROR = 2, |
50 READ_ERROR = 3, | 55 READ_ERROR = 3, |
51 UNEXPECTED_ERROR = 4, | 56 UNEXPECTED_ERROR = 4, |
52 WRITE_ERROR = 5 | 57 WRITE_ERROR = 5 |
53 }; | 58 }; |
54 | 59 |
55 class SourceStream; | |
56 class SinkStream; | |
57 | |
58 // Creates a binary patch. | 60 // Creates a binary patch. |
59 // | 61 // |
60 BSDiffStatus CreateBinaryPatch(SourceStream* old_stream, | 62 BSDiffStatus CreateBinaryPatch(courgette::SourceStream* old_stream, |
61 SourceStream* new_stream, | 63 courgette::SourceStream* new_stream, |
62 SinkStream* patch_stream); | 64 courgette::SinkStream* patch_stream); |
63 | 65 |
64 // Applies the given patch file to a given source file. This method validates | 66 // Applies the given patch file to a given source file. This method validates |
65 // the CRC of the original file stored in the patch file, before applying the | 67 // the CRC of the original file stored in the patch file, before applying the |
66 // patch to it. | 68 // patch to it. |
67 // | 69 // |
68 BSDiffStatus ApplyBinaryPatch(SourceStream* old_stream, | 70 BSDiffStatus ApplyBinaryPatch(courgette::SourceStream* old_stream, |
69 SourceStream* patch_stream, | 71 courgette::SourceStream* patch_stream, |
70 SinkStream* new_stream); | 72 courgette::SinkStream* new_stream); |
71 | 73 |
72 // As above, but simply takes the file paths. | 74 // As above, but simply takes the file paths. |
73 BSDiffStatus ApplyBinaryPatch(const base::FilePath& old_stream, | 75 BSDiffStatus ApplyBinaryPatch(const base::FilePath& old_stream, |
74 const base::FilePath& patch_stream, | 76 const base::FilePath& patch_stream, |
75 const base::FilePath& new_stream); | 77 const base::FilePath& new_stream); |
76 | 78 |
77 // The following declarations are common to the patch-creation and | 79 // The following declarations are common to the patch-creation and |
78 // patch-application code. | 80 // patch-application code. |
79 | 81 |
80 // The patch stream starts with a MBSPatchHeader. | 82 // The patch stream starts with a MBSPatchHeader. |
81 typedef struct MBSPatchHeader_ { | 83 typedef struct MBSPatchHeader_ { |
82 char tag[8]; // Contains MBS_PATCH_HEADER_TAG. | 84 char tag[8]; // Contains MBS_PATCH_HEADER_TAG. |
83 uint32_t slen; // Length of the file to be patched. | 85 uint32_t slen; // Length of the file to be patched. |
84 uint32_t scrc32; // CRC32 of the file to be patched. | 86 uint32_t scrc32; // CRC32 of the file to be patched. |
85 uint32_t dlen; // Length of the result file. | 87 uint32_t dlen; // Length of the result file. |
86 } MBSPatchHeader; | 88 } MBSPatchHeader; |
87 | 89 |
88 // This is the value for the tag field. Must match length exactly, not counting | 90 // This is the value for the tag field. Must match length exactly, not counting |
89 // null at end of string. | 91 // null at end of string. |
90 #define MBS_PATCH_HEADER_TAG "GBSDIF42" | 92 #define MBS_PATCH_HEADER_TAG "GBSDIF42" |
91 | 93 |
92 } // namespace | 94 } // namespace bsdiff |
| 95 |
93 #endif // COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ | 96 #endif // COURGETTE_THIRD_PARTY_BSDIFF_BSDIFF_H_ |
OLD | NEW |