| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 courgette::SinkStream* old_stream = model_sinks.stream(i); | 270 courgette::SinkStream* old_stream = model_sinks.stream(i); |
| 271 courgette::SinkStream* new_stream = program_sinks.stream(i); | 271 courgette::SinkStream* new_stream = program_sinks.stream(i); |
| 272 if (old_stream == NULL && new_stream == NULL) | 272 if (old_stream == NULL && new_stream == NULL) |
| 273 break; | 273 break; |
| 274 | 274 |
| 275 courgette::SourceStream old_source; | 275 courgette::SourceStream old_source; |
| 276 courgette::SourceStream new_source; | 276 courgette::SourceStream new_source; |
| 277 old_source.Init(old_stream ? *old_stream : empty_sink); | 277 old_source.Init(old_stream ? *old_stream : empty_sink); |
| 278 new_source.Init(new_stream ? *new_stream : empty_sink); | 278 new_source.Init(new_stream ? *new_stream : empty_sink); |
| 279 courgette::SinkStream patch_stream; | 279 courgette::SinkStream patch_stream; |
| 280 courgette::BSDiffStatus status = | 280 bsdiff::BSDiffStatus status = |
| 281 courgette::CreateBinaryPatch(&old_source, &new_source, &patch_stream); | 281 bsdiff::CreateBinaryPatch(&old_source, &new_source, &patch_stream); |
| 282 if (status != courgette::OK) Problem("-xxx failed."); | 282 if (status != bsdiff::OK) |
| 283 Problem("-xxx failed."); |
| 283 | 284 |
| 284 std::string append = std::string("-") + base::IntToString(i); | 285 std::string append = std::string("-") + base::IntToString(i); |
| 285 | 286 |
| 286 WriteSinkToFile(&patch_stream, | 287 WriteSinkToFile(&patch_stream, |
| 287 output_file_root.InsertBeforeExtensionASCII(append)); | 288 output_file_root.InsertBeforeExtensionASCII(append)); |
| 288 } | 289 } |
| 289 } | 290 } |
| 290 | 291 |
| 291 void Assemble(const base::FilePath& input_file, | 292 void Assemble(const base::FilePath& input_file, |
| 292 const base::FilePath& output_file) { | 293 const base::FilePath& output_file) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 320 | 321 |
| 321 courgette::SourceStream old_stream; | 322 courgette::SourceStream old_stream; |
| 322 courgette::SourceStream new_stream; | 323 courgette::SourceStream new_stream; |
| 323 old_stream.Init(old_buffer.data(), old_buffer.length()); | 324 old_stream.Init(old_buffer.data(), old_buffer.length()); |
| 324 new_stream.Init(new_buffer.data(), new_buffer.length()); | 325 new_stream.Init(new_buffer.data(), new_buffer.length()); |
| 325 | 326 |
| 326 courgette::SinkStream patch_stream; | 327 courgette::SinkStream patch_stream; |
| 327 courgette::Status status = | 328 courgette::Status status = |
| 328 courgette::GenerateEnsemblePatch(&old_stream, &new_stream, &patch_stream); | 329 courgette::GenerateEnsemblePatch(&old_stream, &new_stream, &patch_stream); |
| 329 | 330 |
| 330 if (status != courgette::C_OK) Problem("-gen failed."); | 331 if (status != courgette::C_OK) |
| 332 Problem("-gen failed."); |
| 331 | 333 |
| 332 WriteSinkToFile(&patch_stream, patch_file); | 334 WriteSinkToFile(&patch_stream, patch_file); |
| 333 } | 335 } |
| 334 | 336 |
| 335 void ApplyEnsemblePatch(const base::FilePath& old_file, | 337 void ApplyEnsemblePatch(const base::FilePath& old_file, |
| 336 const base::FilePath& patch_file, | 338 const base::FilePath& patch_file, |
| 337 const base::FilePath& new_file) { | 339 const base::FilePath& new_file) { |
| 338 // We do things a little differently here in order to call the same Courgette | 340 // We do things a little differently here in order to call the same Courgette |
| 339 // entry point as the installer. That entry point point takes file names and | 341 // entry point as the installer. That entry point point takes file names and |
| 340 // returns an status code but does not output any diagnostics. | 342 // returns an status code but does not output any diagnostics. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 const base::FilePath& patch_file) { | 393 const base::FilePath& patch_file) { |
| 392 BufferedFileReader old_buffer(old_file, "'old' input"); | 394 BufferedFileReader old_buffer(old_file, "'old' input"); |
| 393 BufferedFileReader new_buffer(new_file, "'new' input"); | 395 BufferedFileReader new_buffer(new_file, "'new' input"); |
| 394 | 396 |
| 395 courgette::SourceStream old_stream; | 397 courgette::SourceStream old_stream; |
| 396 courgette::SourceStream new_stream; | 398 courgette::SourceStream new_stream; |
| 397 old_stream.Init(old_buffer.data(), old_buffer.length()); | 399 old_stream.Init(old_buffer.data(), old_buffer.length()); |
| 398 new_stream.Init(new_buffer.data(), new_buffer.length()); | 400 new_stream.Init(new_buffer.data(), new_buffer.length()); |
| 399 | 401 |
| 400 courgette::SinkStream patch_stream; | 402 courgette::SinkStream patch_stream; |
| 401 courgette::BSDiffStatus status = | 403 bsdiff::BSDiffStatus status = |
| 402 courgette::CreateBinaryPatch(&old_stream, &new_stream, &patch_stream); | 404 bsdiff::CreateBinaryPatch(&old_stream, &new_stream, &patch_stream); |
| 403 | 405 |
| 404 if (status != courgette::OK) Problem("-genbsdiff failed."); | 406 if (status != bsdiff::OK) |
| 407 Problem("-genbsdiff failed."); |
| 405 | 408 |
| 406 WriteSinkToFile(&patch_stream, patch_file); | 409 WriteSinkToFile(&patch_stream, patch_file); |
| 407 } | 410 } |
| 408 | 411 |
| 409 void ApplyBSDiffPatch(const base::FilePath& old_file, | 412 void ApplyBSDiffPatch(const base::FilePath& old_file, |
| 410 const base::FilePath& patch_file, | 413 const base::FilePath& patch_file, |
| 411 const base::FilePath& new_file) { | 414 const base::FilePath& new_file) { |
| 412 BufferedFileReader old_buffer(old_file, "'old' input"); | 415 BufferedFileReader old_buffer(old_file, "'old' input"); |
| 413 BufferedFileReader patch_buffer(patch_file, "'patch' input"); | 416 BufferedFileReader patch_buffer(patch_file, "'patch' input"); |
| 414 | 417 |
| 415 courgette::SourceStream old_stream; | 418 courgette::SourceStream old_stream; |
| 416 courgette::SourceStream patch_stream; | 419 courgette::SourceStream patch_stream; |
| 417 old_stream.Init(old_buffer.data(), old_buffer.length()); | 420 old_stream.Init(old_buffer.data(), old_buffer.length()); |
| 418 patch_stream.Init(patch_buffer.data(), patch_buffer.length()); | 421 patch_stream.Init(patch_buffer.data(), patch_buffer.length()); |
| 419 | 422 |
| 420 courgette::SinkStream new_stream; | 423 courgette::SinkStream new_stream; |
| 421 courgette::BSDiffStatus status = | 424 bsdiff::BSDiffStatus status = |
| 422 courgette::ApplyBinaryPatch(&old_stream, &patch_stream, &new_stream); | 425 bsdiff::ApplyBinaryPatch(&old_stream, &patch_stream, &new_stream); |
| 423 | 426 |
| 424 if (status != courgette::OK) Problem("-applybsdiff failed."); | 427 if (status != bsdiff::OK) |
| 428 Problem("-applybsdiff failed."); |
| 425 | 429 |
| 426 WriteSinkToFile(&new_stream, new_file); | 430 WriteSinkToFile(&new_stream, new_file); |
| 427 } | 431 } |
| 428 | 432 |
| 429 int main(int argc, const char* argv[]) { | 433 int main(int argc, const char* argv[]) { |
| 430 base::AtExitManager at_exit_manager; | 434 base::AtExitManager at_exit_manager; |
| 431 base::CommandLine::Init(argc, argv); | 435 base::CommandLine::Init(argc, argv); |
| 432 const base::CommandLine& command_line = | 436 const base::CommandLine& command_line = |
| 433 *base::CommandLine::ForCurrentProcess(); | 437 *base::CommandLine::ForCurrentProcess(); |
| 434 | 438 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); | 514 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); |
| 511 DisassembleAdjustDiff(values[0], values[1], values[2], | 515 DisassembleAdjustDiff(values[0], values[1], values[2], |
| 512 cmd_spread_1_adjusted); | 516 cmd_spread_1_adjusted); |
| 513 } else { | 517 } else { |
| 514 UsageProblem("No operation specified"); | 518 UsageProblem("No operation specified"); |
| 515 } | 519 } |
| 516 } | 520 } |
| 517 | 521 |
| 518 return 0; | 522 return 0; |
| 519 } | 523 } |
| OLD | NEW |