23 EggMultiFilter(
bool allow_empty) : _allow_empty(allow_empty) {
25 add_runline(
"-o output.egg [opts] input.egg");
26 add_runline(
"-d dirname [opts] file.egg [file.egg ...]");
27 add_runline(
"-inplace [opts] file.egg [file.egg ...]");
28 add_runline(
"-inf input_list_filename [opts]");
32 "Specify the filename to which the resulting egg file will be written. "
33 "This is only valid when there is only one input egg file on the command "
34 "line. If you want to process multiple files simultaneously, you must "
35 "use either -d or -inplace.",
36 &EggMultiFilter::dispatch_filename, &_got_output_filename, &_output_filename);
40 "Specify the name of the directory in which to write the resulting egg "
41 "files. If you are processing only one egg file, this may be omitted "
42 "in lieu of the -o option. If you are processing multiple egg files, "
43 "this may be omitted only if you specify -inplace instead.",
44 &EggMultiFilter::dispatch_filename, &_got_output_dirname, &_output_dirname);
48 "If this option is given, the input egg files will be rewritten in "
49 "place with the results. This obviates the need to specify -d "
50 "for an output directory; however, it's risky because the original "
51 "input egg files are lost.",
52 &EggMultiFilter::dispatch_none, &_inplace);
55 (
"inf",
"filename", 95,
56 "Reads input args from a text file instead of the command line. "
57 "Useful for really, really large lists of args that break the "
58 "OS-imposed limits on the length of command lines.",
59 &EggMultiFilter::dispatch_filename, &_got_input_filename, &_input_filename);
75 if (_got_input_filename) {
76 nout <<
"Populating args from input file: " << _input_filename <<
"\n";
78 _filename = Filename::text_filename(_input_filename);
81 nout <<
"Error opening file: " << _input_filename <<
"\n";
86 while (std::getline(input, line,
' ')) {
92 nout <<
"You must specify the egg file(s) to read on the command line.\n";
97 if (_got_output_filename && args.size() == 1) {
98 if (_got_output_dirname) {
99 nout <<
"Cannot specify both -o and -d.\n";
101 }
else if (_inplace) {
102 nout <<
"Cannot specify both -o and -inplace.\n";
107 if (_got_output_filename) {
108 nout <<
"Cannot use -o when multiple egg files are specified.\n";
112 if (_got_output_dirname && _inplace) {
113 nout <<
"Cannot specify both -inplace and -d.\n";
116 }
else if (!_got_output_dirname && !_inplace) {
118 nout <<
"You must specify either -inplace or -d.\n";
126 if (!_got_path_directory) {
128 if (_got_output_filename) {
129 _path_replace->_path_directory = _output_filename.
get_dirname();
130 }
else if (_got_output_dirname) {
131 _path_replace->_path_directory = _output_dirname;
135 Args::const_iterator ai;
136 for (ai = args.begin(); ai != args.end(); ++ai) {
138 if (data ==
nullptr) {
145 _eggs.push_back(data);
154 bool EggMultiFilter::
155 post_command_line() {
157 for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
159 if (_got_coordinate_system) {
160 data->set_coordinate_system(_coordinate_system);
162 append_command_comment(data);
165 return EggMultiBase::post_command_line();
173 get_output_filename(
const Filename &source_filename)
const {
174 if (_got_output_filename) {
175 nassertr(!_inplace && !_got_output_dirname && _eggs.size() == 1,
Filename());
176 return _output_filename;
178 }
else if (_got_output_dirname) {
186 return source_filename;
194 void EggMultiFilter::
196 nassertv(!_read_only);
199 for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
201 Filename filename = get_output_filename(data->get_egg_filename());
203 nout <<
"Writing " << filename <<
"\n";
205 if (!data->write_egg(filename)) {