| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 #include "courgette/third_party/bsdiff/bsdiff.h" | 37 #include "courgette/third_party/bsdiff/bsdiff.h" |
| 38 | 38 |
| 39 #include <stddef.h> | 39 #include <stddef.h> |
| 40 #include <stdint.h> | 40 #include <stdint.h> |
| 41 | 41 |
| 42 #include "base/files/memory_mapped_file.h" | 42 #include "base/files/memory_mapped_file.h" |
| 43 #include "courgette/crc.h" | 43 #include "courgette/crc.h" |
| 44 #include "courgette/streams.h" | 44 #include "courgette/streams.h" |
| 45 | 45 |
| 46 namespace courgette { | 46 namespace { |
| 47 |
| 48 using courgette::CalculateCrc; |
| 49 using courgette::SinkStream; |
| 50 using courgette::SinkStreamSet; |
| 51 using courgette::SourceStream; |
| 52 using courgette::SourceStreamSet; |
| 53 |
| 54 } // namespace |
| 55 |
| 56 namespace bsdiff { |
| 47 | 57 |
| 48 BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) { | 58 BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) { |
| 49 if (!stream->Read(header->tag, sizeof(header->tag))) | 59 if (!stream->Read(header->tag, sizeof(header->tag))) |
| 50 return READ_ERROR; | 60 return READ_ERROR; |
| 51 if (!stream->ReadVarint32(&header->slen)) | 61 if (!stream->ReadVarint32(&header->slen)) |
| 52 return READ_ERROR; | 62 return READ_ERROR; |
| 53 if (!stream->ReadVarint32(&header->scrc32)) | 63 if (!stream->ReadVarint32(&header->scrc32)) |
| 54 return READ_ERROR; | 64 return READ_ERROR; |
| 55 if (!stream->ReadVarint32(&header->dlen)) | 65 if (!stream->ReadVarint32(&header->dlen)) |
| 56 return READ_ERROR; | 66 return READ_ERROR; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 217 |
| 208 // Write the stream to disk. | 218 // Write the stream to disk. |
| 209 int written = base::WriteFile( | 219 int written = base::WriteFile( |
| 210 new_file_path, reinterpret_cast<const char*>(new_sink_stream.Buffer()), | 220 new_file_path, reinterpret_cast<const char*>(new_sink_stream.Buffer()), |
| 211 static_cast<int>(new_sink_stream.Length())); | 221 static_cast<int>(new_sink_stream.Length())); |
| 212 if (written != static_cast<int>(new_sink_stream.Length())) | 222 if (written != static_cast<int>(new_sink_stream.Length())) |
| 213 return WRITE_ERROR; | 223 return WRITE_ERROR; |
| 214 return OK; | 224 return OK; |
| 215 } | 225 } |
| 216 | 226 |
| 217 } // namespace | 227 } // namespace bsdiff |
| OLD | NEW |