15 #include "eggMultiFilter.h" 26 EggMultiFilter(
bool allow_empty) : _allow_empty(allow_empty) {
28 add_runline(
"-o output.egg [opts] input.egg");
29 add_runline(
"-d dirname [opts] file.egg [file.egg ...]");
30 add_runline(
"-inplace [opts] file.egg [file.egg ...]");
31 add_runline(
"-inf input_list_filename [opts]");
35 "Specify the filename to which the resulting egg file will be written. " 36 "This is only valid when there is only one input egg file on the command " 37 "line. If you want to process multiple files simultaneously, you must " 38 "use either -d or -inplace.",
39 &EggMultiFilter::dispatch_filename, &_got_output_filename, &_output_filename);
43 "Specify the name of the directory in which to write the resulting egg " 44 "files. If you are processing only one egg file, this may be omitted " 45 "in lieu of the -o option. If you are processing multiple egg files, " 46 "this may be omitted only if you specify -inplace instead.",
47 &EggMultiFilter::dispatch_filename, &_got_output_dirname, &_output_dirname);
51 "If this option is given, the input egg files will be rewritten in " 52 "place with the results. This obviates the need to specify -d " 53 "for an output directory; however, it's risky because the original " 54 "input egg files are lost.",
55 &EggMultiFilter::dispatch_none, &_inplace);
58 (
"inf",
"filename", 95,
59 "Reads input args from a text file instead of the command line. " 60 "Useful for really, really large lists of args that break the " 61 "OS-imposed limits on the length of command lines.",
62 &EggMultiFilter::dispatch_filename, &_got_input_filename, &_input_filename);
82 if (_got_input_filename) {
83 nout <<
"Populating args from input file: " << _input_filename <<
"\n";
85 _filename = Filename::text_filename(_input_filename);
87 if (!_filename.open_read(input)) {
88 nout <<
"Error opening file: " << _input_filename <<
"\n";
93 while (getline(input, line,
' ')) {
99 nout <<
"You must specify the egg file(s) to read on the command line.\n";
104 if (_got_output_filename && args.size() == 1) {
105 if (_got_output_dirname) {
106 nout <<
"Cannot specify both -o and -d.\n";
108 }
else if (_inplace) {
109 nout <<
"Cannot specify both -o and -inplace.\n";
114 if (_got_output_filename) {
115 nout <<
"Cannot use -o when multiple egg files are specified.\n";
119 if (_got_output_dirname && _inplace) {
120 nout <<
"Cannot specify both -inplace and -d.\n";
123 }
else if (!_got_output_dirname && !_inplace) {
125 nout <<
"You must specify either -inplace or -d.\n";
133 if (!_got_path_directory) {
135 if (_got_output_filename) {
136 _path_replace->_path_directory = _output_filename.get_dirname();
137 }
else if (_got_output_dirname) {
138 _path_replace->_path_directory = _output_dirname;
142 Args::const_iterator ai;
143 for (ai = args.begin(); ai != args.end(); ++ai) {
152 _eggs.push_back(data);
163 bool EggMultiFilter::
164 post_command_line() {
166 for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
168 if (_got_coordinate_system) {
171 append_command_comment(data);
174 return EggMultiBase::post_command_line();
185 get_output_filename(
const Filename &source_filename)
const {
186 if (_got_output_filename) {
187 nassertr(!_inplace && !_got_output_dirname && _eggs.size() == 1,
Filename());
188 return _output_filename;
190 }
else if (_got_output_dirname) {
198 return source_filename;
208 void EggMultiFilter::
210 nassertv(!_read_only);
213 for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
217 nout <<
"Writing " << filename <<
"\n";
bool write_egg(Filename filename)
The main interface for writing complete egg files.
const Filename & get_egg_filename() const
Returns the directory in which the egg file is considered to reside.
This is the primary interface into all the egg data, and the root of the egg file structure...
void set_coordinate_system(CoordinateSystem coordsys)
Changes the coordinate system of the EggData.
The name of a file, such as a texture file or an Egg file.
void set_dirname(const string &s)
Replaces the directory part of the filename.
void post_process_egg_files()
Performs any processing of the egg file(s) that is appropriate before writing them out...
bool make_dir() const
Creates all the directories in the path to the file specified in the filename, except for the basenam...
static Filename from_os_specific(const string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes, and no drive letter) based on the supplied filename string that describes a filename in the local system conventions (for instance, on Windows, it may use backslashes or begin with a drive letter and a colon).