Panda3D
apply_patch.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file apply_patch.cxx
10  */
11 
12 #include "pandabase.h"
13 #include "panda_getopt.h"
14 #include "preprocess_argv.h"
15 #include "patchfile.h"
16 #include "filename.h"
17 
18 using std::cerr;
19 using std::endl;
20 
21 int
22 main(int argc, char **argv) {
23  preprocess_argv(argc, argv);
24 
25  if (argc < 3) {
26  cerr << "Usage: apply_patch <patch_file> <old_file>" << endl;
27  cerr << "Will overwrite old_file" << endl;
28  return 1;
29  }
30 
31  Filename patch = argv[1];
32  patch.set_binary();
33 
34  Filename file = argv[2];
35  file.set_binary();
36 
37  Patchfile pfile;
38 
39  cerr << "Applying patch file " << patch << " to " << file << endl;
40  if (pfile.apply(patch, file) == false) {
41  cerr << "apply patch failed" << endl;
42  return 1;
43  }
44 
45  return 0;
46 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_binary()
Indicates that the filename represents a binary file.
Definition: filename.I:414
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void preprocess_argv(int &argc, char **&argv)
Processes the argc, argv pair as needed before passing it to getopt().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.