Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: courgette/courgette_tool.cc

Issue 2031193002: [Courgette] Refactor BSDiff namespaces and bsdiff::search() interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more gap; fix Installer confusion; update README.chromium. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 courgette::SinkStream* old_stream = model_sinks.stream(i); 273 courgette::SinkStream* old_stream = model_sinks.stream(i);
274 courgette::SinkStream* new_stream = program_sinks.stream(i); 274 courgette::SinkStream* new_stream = program_sinks.stream(i);
275 if (old_stream == NULL && new_stream == NULL) 275 if (old_stream == NULL && new_stream == NULL)
276 break; 276 break;
277 277
278 courgette::SourceStream old_source; 278 courgette::SourceStream old_source;
279 courgette::SourceStream new_source; 279 courgette::SourceStream new_source;
280 old_source.Init(old_stream ? *old_stream : empty_sink); 280 old_source.Init(old_stream ? *old_stream : empty_sink);
281 new_source.Init(new_stream ? *new_stream : empty_sink); 281 new_source.Init(new_stream ? *new_stream : empty_sink);
282 courgette::SinkStream patch_stream; 282 courgette::SinkStream patch_stream;
283 courgette::BSDiffStatus status = 283 bsdiff::BSDiffStatus status =
284 courgette::CreateBinaryPatch(&old_source, &new_source, &patch_stream); 284 bsdiff::CreateBinaryPatch(&old_source, &new_source, &patch_stream);
285 if (status != courgette::OK) Problem("-xxx failed."); 285 if (status != bsdiff::OK) Problem("-xxx failed.");
286 286
287 std::string append = std::string("-") + base::IntToString(i); 287 std::string append = std::string("-") + base::IntToString(i);
288 288
289 WriteSinkToFile(&patch_stream, 289 WriteSinkToFile(&patch_stream,
290 output_file_root.InsertBeforeExtensionASCII(append)); 290 output_file_root.InsertBeforeExtensionASCII(append));
291 } 291 }
292 } 292 }
293 293
294 void Assemble(const base::FilePath& input_file, 294 void Assemble(const base::FilePath& input_file,
295 const base::FilePath& output_file) { 295 const base::FilePath& output_file) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 const base::FilePath& patch_file) { 397 const base::FilePath& patch_file) {
398 std::string old_buffer = ReadOrFail(old_file, "'old' input"); 398 std::string old_buffer = ReadOrFail(old_file, "'old' input");
399 std::string new_buffer = ReadOrFail(new_file, "'new' input"); 399 std::string new_buffer = ReadOrFail(new_file, "'new' input");
400 400
401 courgette::SourceStream old_stream; 401 courgette::SourceStream old_stream;
402 courgette::SourceStream new_stream; 402 courgette::SourceStream new_stream;
403 old_stream.Init(old_buffer); 403 old_stream.Init(old_buffer);
404 new_stream.Init(new_buffer); 404 new_stream.Init(new_buffer);
405 405
406 courgette::SinkStream patch_stream; 406 courgette::SinkStream patch_stream;
407 courgette::BSDiffStatus status = 407 bsdiff::BSDiffStatus status =
408 courgette::CreateBinaryPatch(&old_stream, &new_stream, &patch_stream); 408 bsdiff::CreateBinaryPatch(&old_stream, &new_stream, &patch_stream);
409 409
410 if (status != courgette::OK) Problem("-genbsdiff failed."); 410 if (status != bsdiff::OK) Problem("-genbsdiff failed.");
411 411
412 WriteSinkToFile(&patch_stream, patch_file); 412 WriteSinkToFile(&patch_stream, patch_file);
413 } 413 }
414 414
415 void ApplyBSDiffPatch(const base::FilePath& old_file, 415 void ApplyBSDiffPatch(const base::FilePath& old_file,
416 const base::FilePath& patch_file, 416 const base::FilePath& patch_file,
417 const base::FilePath& new_file) { 417 const base::FilePath& new_file) {
418 std::string old_buffer = ReadOrFail(old_file, "'old' input"); 418 std::string old_buffer = ReadOrFail(old_file, "'old' input");
419 std::string patch_buffer = ReadOrFail(patch_file, "'patch' input"); 419 std::string patch_buffer = ReadOrFail(patch_file, "'patch' input");
420 420
421 courgette::SourceStream old_stream; 421 courgette::SourceStream old_stream;
422 courgette::SourceStream patch_stream; 422 courgette::SourceStream patch_stream;
423 old_stream.Init(old_buffer); 423 old_stream.Init(old_buffer);
424 patch_stream.Init(patch_buffer); 424 patch_stream.Init(patch_buffer);
425 425
426 courgette::SinkStream new_stream; 426 courgette::SinkStream new_stream;
427 courgette::BSDiffStatus status = 427 bsdiff::BSDiffStatus status =
428 courgette::ApplyBinaryPatch(&old_stream, &patch_stream, &new_stream); 428 bsdiff::ApplyBinaryPatch(&old_stream, &patch_stream, &new_stream);
429 429
430 if (status != courgette::OK) Problem("-applybsdiff failed."); 430 if (status != bsdiff::OK) Problem("-applybsdiff failed.");
431 431
432 WriteSinkToFile(&new_stream, new_file); 432 WriteSinkToFile(&new_stream, new_file);
433 } 433 }
434 434
435 int main(int argc, const char* argv[]) { 435 int main(int argc, const char* argv[]) {
436 base::AtExitManager at_exit_manager; 436 base::AtExitManager at_exit_manager;
437 base::CommandLine::Init(argc, argv); 437 base::CommandLine::Init(argc, argv);
438 const base::CommandLine& command_line = 438 const base::CommandLine& command_line =
439 *base::CommandLine::ForCurrentProcess(); 439 *base::CommandLine::ForCurrentProcess();
440 440
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); 516 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>");
517 DisassembleAdjustDiff(values[0], values[1], values[2], 517 DisassembleAdjustDiff(values[0], values[1], values[2],
518 cmd_spread_1_adjusted); 518 cmd_spread_1_adjusted);
519 } else { 519 } else {
520 UsageProblem("No operation specified"); 520 UsageProblem("No operation specified");
521 } 521 }
522 } 522 }
523 523
524 return 0; 524 return 0;
525 } 525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698