| OLD | NEW |
| 1 // Copyright (c) 2009 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 <vector> | 5 #include <vector> |
| 6 #include <string> | 6 #include <string> |
| 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" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 FilePath old_path(old_file); | 296 FilePath old_path(old_file); |
| 297 FilePath patch_path(patch_file); | 297 FilePath patch_path(patch_file); |
| 298 FilePath new_path(new_file); | 298 FilePath new_path(new_file); |
| 299 #else | 299 #else |
| 300 FilePath old_path(WideToASCII(old_file)); | 300 FilePath old_path(WideToASCII(old_file)); |
| 301 FilePath patch_path(WideToASCII(patch_file)); | 301 FilePath patch_path(WideToASCII(patch_file)); |
| 302 FilePath new_path(WideToASCII(new_file)); | 302 FilePath new_path(WideToASCII(new_file)); |
| 303 #endif | 303 #endif |
| 304 | 304 |
| 305 courgette::Status status = | 305 courgette::Status status = |
| 306 courgette::ApplyEnsemblePatch(old_path.value().c_str(), | 306 courgette::ApplyEnsemblePatch(old_path.value().c_str(), |
| 307 patch_path.value().c_str(), | 307 patch_path.value().c_str(), |
| 308 new_path.value().c_str()); | 308 new_path.value().c_str()); |
| 309 | 309 |
| 310 if (status == courgette::C_OK) | 310 if (status == courgette::C_OK) |
| 311 return; | 311 return; |
| 312 | 312 |
| 313 // Diagnose the error. | 313 // Diagnose the error. |
| 314 if (status == courgette::C_BAD_ENSEMBLE_MAGIC) | 314 switch (status) { |
| 315 Problem("Not a courgette patch"); | 315 case courgette::C_BAD_ENSEMBLE_MAGIC: |
| 316 if (status == courgette::C_BAD_ENSEMBLE_VERSION) | 316 Problem("Not a courgette patch"); |
| 317 Problem("Wrong version patch"); | 317 break; |
| 318 if (status == courgette::C_BAD_ENSEMBLE_HEADER) | 318 |
| 319 Problem("Corrupt patch"); | 319 case courgette::C_BAD_ENSEMBLE_VERSION: |
| 320 Problem("Wrong version patch"); |
| 321 break; |
| 322 |
| 323 case courgette::C_BAD_ENSEMBLE_HEADER: |
| 324 Problem("Corrupt patch"); |
| 325 break; |
| 326 |
| 327 case courgette::C_DISASSEMBLY_FAILED: |
| 328 Problem("Disassembly failed (could be because of memory issues)"); |
| 329 break; |
| 330 |
| 331 case courgette::C_STREAM_ERROR: |
| 332 Problem("Stream error (likely out of memory or disk space)"); |
| 333 break; |
| 334 |
| 335 default: |
| 336 break; |
| 337 } |
| 338 |
| 320 // If we failed due to a missing input file, this will | 339 // If we failed due to a missing input file, this will |
| 321 // print the message. | 340 // print the message. |
| 322 std::string old_buffer = ReadOrFail(old_file, "'old' input"); | 341 std::string old_buffer = ReadOrFail(old_file, "'old' input"); |
| 323 old_buffer.clear(); | 342 old_buffer.clear(); |
| 324 std::string patch_buffer = ReadOrFail(patch_file, "'patch' input"); | 343 std::string patch_buffer = ReadOrFail(patch_file, "'patch' input"); |
| 325 patch_buffer.clear(); | 344 patch_buffer.clear(); |
| 326 | 345 |
| 327 // Non-input related errors: | 346 // Non-input related errors: |
| 328 if (status == courgette::C_WRITE_OPEN_ERROR) | 347 if (status == courgette::C_WRITE_OPEN_ERROR) |
| 329 Problem("Can't open output"); | 348 Problem("Can't open output"); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } else if (cmd_spread_1_adjusted || cmd_spread_1_unadjusted) { | 473 } else if (cmd_spread_1_adjusted || cmd_spread_1_unadjusted) { |
| 455 if (values.size() != 3) | 474 if (values.size() != 3) |
| 456 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); | 475 UsageProblem("-gen1[au] <old_file> <new_file> <patch_files_root>"); |
| 457 DisassembleAdjustDiff(values[0], values[1], values[2], | 476 DisassembleAdjustDiff(values[0], values[1], values[2], |
| 458 cmd_spread_1_adjusted); | 477 cmd_spread_1_adjusted); |
| 459 } else { | 478 } else { |
| 460 UsageProblem("No operation specified"); | 479 UsageProblem("No operation specified"); |
| 461 } | 480 } |
| 462 } | 481 } |
| 463 } | 482 } |
| OLD | NEW |