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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 courgette::BSDiffStatus status = | 419 courgette::BSDiffStatus status = |
420 courgette::ApplyBinaryPatch(&old_stream, &patch_stream, &new_stream); | 420 courgette::ApplyBinaryPatch(&old_stream, &patch_stream, &new_stream); |
421 | 421 |
422 if (status != courgette::OK) Problem("-applybsdiff failed."); | 422 if (status != courgette::OK) Problem("-applybsdiff failed."); |
423 | 423 |
424 WriteSinkToFile(&new_stream, new_file); | 424 WriteSinkToFile(&new_stream, new_file); |
425 } | 425 } |
426 | 426 |
427 int main(int argc, const char* argv[]) { | 427 int main(int argc, const char* argv[]) { |
428 base::AtExitManager at_exit_manager; | 428 base::AtExitManager at_exit_manager; |
429 CommandLine::Init(argc, argv); | 429 base::CommandLine::Init(argc, argv); |
430 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 430 const base::CommandLine& command_line = |
| 431 *base::CommandLine::ForCurrentProcess(); |
431 | 432 |
432 logging::LoggingSettings settings; | 433 logging::LoggingSettings settings; |
433 settings.logging_dest = logging::LOG_TO_ALL; | 434 settings.logging_dest = logging::LOG_TO_ALL; |
434 settings.log_file = FILE_PATH_LITERAL("courgette.log"); | 435 settings.log_file = FILE_PATH_LITERAL("courgette.log"); |
435 (void)logging::InitLogging(settings); | 436 (void)logging::InitLogging(settings); |
436 logging::SetMinLogLevel(logging::LOG_VERBOSE); | 437 logging::SetMinLogLevel(logging::LOG_VERBOSE); |
437 | 438 |
438 bool cmd_sup = command_line.HasSwitch("supported"); | 439 bool cmd_sup = command_line.HasSwitch("supported"); |
439 bool cmd_dis = command_line.HasSwitch("dis"); | 440 bool cmd_dis = command_line.HasSwitch("dis"); |
440 bool cmd_asm = command_line.HasSwitch("asm"); | 441 bool cmd_asm = command_line.HasSwitch("asm"); |
441 bool cmd_disadj = command_line.HasSwitch("disadj"); | 442 bool cmd_disadj = command_line.HasSwitch("disadj"); |
442 bool cmd_make_patch = command_line.HasSwitch("gen"); | 443 bool cmd_make_patch = command_line.HasSwitch("gen"); |
443 bool cmd_apply_patch = command_line.HasSwitch("apply"); | 444 bool cmd_apply_patch = command_line.HasSwitch("apply"); |
444 bool cmd_make_bsdiff_patch = command_line.HasSwitch("genbsdiff"); | 445 bool cmd_make_bsdiff_patch = command_line.HasSwitch("genbsdiff"); |
445 bool cmd_apply_bsdiff_patch = command_line.HasSwitch("applybsdiff"); | 446 bool cmd_apply_bsdiff_patch = command_line.HasSwitch("applybsdiff"); |
446 bool cmd_spread_1_adjusted = command_line.HasSwitch("gen1a"); | 447 bool cmd_spread_1_adjusted = command_line.HasSwitch("gen1a"); |
447 bool cmd_spread_1_unadjusted = command_line.HasSwitch("gen1u"); | 448 bool cmd_spread_1_unadjusted = command_line.HasSwitch("gen1u"); |
448 | 449 |
449 std::vector<base::FilePath> values; | 450 std::vector<base::FilePath> values; |
450 const CommandLine::StringVector& args = command_line.GetArgs(); | 451 const base::CommandLine::StringVector& args = command_line.GetArgs(); |
451 for (size_t i = 0; i < args.size(); ++i) { | 452 for (size_t i = 0; i < args.size(); ++i) { |
452 values.push_back(base::FilePath(args[i])); | 453 values.push_back(base::FilePath(args[i])); |
453 } | 454 } |
454 | 455 |
455 // '-repeat=N' is for debugging. Running many iterations can reveal leaks and | 456 // '-repeat=N' is for debugging. Running many iterations can reveal leaks and |
456 // bugs in cleanup. | 457 // bugs in cleanup. |
457 int repeat_count = 1; | 458 int repeat_count = 1; |
458 std::string repeat_switch = command_line.GetSwitchValueASCII("repeat"); | 459 std::string repeat_switch = command_line.GetSwitchValueASCII("repeat"); |
459 if (!repeat_switch.empty()) | 460 if (!repeat_switch.empty()) |
460 if (!base::StringToInt(repeat_switch, &repeat_count)) | 461 if (!base::StringToInt(repeat_switch, &repeat_count)) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); | 508 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); |
508 DisassembleAdjustDiff(values[0], values[1], values[2], | 509 DisassembleAdjustDiff(values[0], values[1], values[2], |
509 cmd_spread_1_adjusted); | 510 cmd_spread_1_adjusted); |
510 } else { | 511 } else { |
511 UsageProblem("No operation specified"); | 512 UsageProblem("No operation specified"); |
512 } | 513 } |
513 } | 514 } |
514 | 515 |
515 return 0; | 516 return 0; |
516 } | 517 } |
OLD | NEW |