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