Panda3D
testCopy.cxx
1 // Filename: testCopy.cxx
2 // Created by: drose (31Oct00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "testCopy.h"
16 #include "cvsSourceDirectory.h"
17 #include "pystub.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: TestCopy::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 TestCopy::
25 TestCopy() {
26  set_program_brief("copy files into a CVS source hierarchy");
27  set_program_description
28  ("This program copies one or more files into a CVS source hierarchy. "
29  "Rather than copying the named files immediately into the current "
30  "directory, it first scans the entire source hierarchy, identifying all "
31  "the already-existing files. If the named file to copy matches the "
32  "name of an already-existing file in the current directory or elsewhere "
33  "in the hierarchy, that file is overwritten.\n\n"
34 
35  "This is primarily useful as a test program for libcvscopy.");
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: TestCopy::run
40 // Access: Public
41 // Description:
42 ////////////////////////////////////////////////////////////////////
43 void TestCopy::
44 run() {
45  SourceFiles::iterator fi;
46  for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) {
47  CVSSourceDirectory *dest = import(*fi, 0, _model_dir);
48  if (dest == (CVSSourceDirectory *)NULL) {
49  exit(1);
50  }
51  }
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: TestCopy::copy_file
56 // Access: Protected, Virtual
57 // Description: Called by import() if the timestamps indicate that a
58 // file needs to be copied. This does the actual copy
59 // of a file from source to destination. If new_file is
60 // true, then dest does not already exist.
61 ////////////////////////////////////////////////////////////////////
62 bool TestCopy::
63 copy_file(const Filename &source, const Filename &dest,
64  CVSSourceDirectory *, void *, bool) {
65  return copy_binary_file(source, dest);
66 }
67 
68 
69 int main(int argc, char *argv[]) {
70  // A call to pystub() to force libpystub.so to be linked in.
71  pystub();
72 
73  TestCopy prog;
74  prog.parse_command_line(argc, argv);
75  prog.run();
76  return 0;
77 }
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
This represents one particular directory in the hierarchy of source directory files.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
A program to copy ordinary files into the cvs tree.
Definition: testCopy.h:27