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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace courgette { | 43 namespace courgette { |
44 | 44 |
45 BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) { | 45 BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) { |
46 if (!stream->Read(header->tag, sizeof(header->tag))) return READ_ERROR; | 46 if (!stream->Read(header->tag, sizeof(header->tag))) return READ_ERROR; |
47 if (!stream->ReadVarint32(&header->slen)) return READ_ERROR; | 47 if (!stream->ReadVarint32(&header->slen)) return READ_ERROR; |
48 if (!stream->ReadVarint32(&header->scrc32)) return READ_ERROR; | 48 if (!stream->ReadVarint32(&header->scrc32)) return READ_ERROR; |
49 if (!stream->ReadVarint32(&header->dlen)) return READ_ERROR; | 49 if (!stream->ReadVarint32(&header->dlen)) return READ_ERROR; |
50 | 50 |
51 // The string will have a NUL terminator that we don't use, hence '-1'. | 51 // The string will have a NUL terminator that we don't use, hence '-1'. |
52 COMPILE_ASSERT(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header->tag), | 52 static_assert(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header->tag), |
53 MBS_PATCH_HEADER_TAG_must_match_header_field_size); | 53 "MBS_PATCH_HEADER_TAG must match header field size"); |
54 if (memcmp(header->tag, MBS_PATCH_HEADER_TAG, 8) != 0) | 54 if (memcmp(header->tag, MBS_PATCH_HEADER_TAG, 8) != 0) |
55 return UNEXPECTED_ERROR; | 55 return UNEXPECTED_ERROR; |
56 | 56 |
57 return OK; | 57 return OK; |
58 } | 58 } |
59 | 59 |
60 BSDiffStatus MBS_ApplyPatch(const MBSPatchHeader *header, | 60 BSDiffStatus MBS_ApplyPatch(const MBSPatchHeader *header, |
61 SourceStream* patch_stream, | 61 SourceStream* patch_stream, |
62 const uint8* old_start, size_t old_size, | 62 const uint8* old_start, size_t old_size, |
63 SinkStream* new_stream) { | 63 SinkStream* new_stream) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 int written = base::WriteFile( | 203 int written = base::WriteFile( |
204 new_file_path, | 204 new_file_path, |
205 reinterpret_cast<const char*>(new_sink_stream.Buffer()), | 205 reinterpret_cast<const char*>(new_sink_stream.Buffer()), |
206 static_cast<int>(new_sink_stream.Length())); | 206 static_cast<int>(new_sink_stream.Length())); |
207 if (written != static_cast<int>(new_sink_stream.Length())) | 207 if (written != static_cast<int>(new_sink_stream.Length())) |
208 return WRITE_ERROR; | 208 return WRITE_ERROR; |
209 return OK; | 209 return OK; |
210 } | 210 } |
211 | 211 |
212 } // namespace | 212 } // namespace |
OLD | NEW |