Make the fling acceleration curve be easily configurable.
[chromium-blink-merge.git] / courgette / courgette_minimal_tool.cc
blob2fd32c1789cdfa5c570d372738667e4427cd401f
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // 'courgette_minimal_tool' is not meant to be a serious command-line tool. It
6 // has the minimum logic to apply a Courgette patch to a file. The main purpose
7 // is to monitor the code size of the patcher.
9 #include <string>
11 #include "base/file_util.h"
13 #include "courgette/third_party/bsdiff.h"
14 #include "courgette/courgette.h"
15 #include "courgette/streams.h"
17 void PrintHelp() {
18 fprintf(stderr,
19 "Usage:\n"
20 " courgette_minimal_tool <old-file-input> <patch-file-input>"
21 " <new-file-output>\n"
22 "\n");
25 void UsageProblem(const char* message) {
26 fprintf(stderr, "%s\n", message);
27 PrintHelp();
28 exit(1);
31 void Problem(const char* message) {
32 fprintf(stderr, "%s\n", message);
33 exit(1);
36 #if defined(OS_WIN)
37 int wmain(int argc, const wchar_t* argv[]) {
38 #else
39 int main(int argc, const char* argv[]) {
40 #endif
41 if (argc != 4)
42 UsageProblem("bad args");
44 courgette::Status status =
45 courgette::ApplyEnsemblePatch(argv[1], argv[2], argv[3]);
47 if (status != courgette::C_OK) {
48 if (status == courgette::C_READ_OPEN_ERROR) Problem("Can't open file.");
49 if (status == courgette::C_WRITE_OPEN_ERROR) Problem("Can't open file.");
50 if (status == courgette::C_READ_ERROR) Problem("Can't read from file.");
51 if (status == courgette::C_WRITE_ERROR) Problem("Can't write to file.");
52 Problem("patch failed.");
55 return 0;