28 set_program_brief(
"copy MultiGen .flt files into a CVS source hierarchy");
29 set_program_description
30 (
"fltcopy copies one or more MultiGen .flt files into a "
31 "CVS source hierarchy. "
32 "Rather than copying the named files immediately into the current "
33 "directory, it first scans the entire source hierarchy, identifying all "
34 "the already-existing files. If the named file to copy matches the "
35 "name of an already-existing file in the current directory or elsewhere "
36 "in the hierarchy, that file is overwritten. Other .flt files, as "
37 "well as texture files, that are externally referenced by the "
38 "named .flt file(s) are similarly copied.");
41 add_runline(
"[opts] file.flt [file.flt ... ]");
43 add_path_replace_options();
51 SourceFiles::iterator fi;
52 for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) {
71 ExtraData *ed = (ExtraData *)extra_data;
74 return copy_flt_file(source, dest, dir);
77 return copy_texture(source, dest, dir, ed->_texture, new_file);
80 nout <<
"Internal error: invalid type " << (int)ed->_type <<
"\n";
94 header->set_auto_attr_update(FltHeader::AU_none);
96 FltError result = header->read_flt(source);
97 if (result != FE_ok) {
98 nout <<
"Cannot read " << source <<
": " << result <<
"\n";
102 header->check_version();
107 scan_flt(header, refs, textures);
109 Refs::const_iterator ri;
110 for (ri = refs.begin(); ri != refs.end(); ++ri) {
114 if (!ref_filename.
exists()) {
115 nout <<
"*** Warning: external reference " << ref_filename
116 <<
" does not exist.\n";
122 import(ref_filename, &ed, _model_dir);
136 header->clear_textures();
138 Textures::const_iterator ti;
139 for (ti = textures.begin(); ti != textures.end(); ++ti) {
143 if (!texture_filename.
exists()) {
144 nout <<
"*** Warning: texture " << texture_filename
145 <<
" does not exist.\n";
148 ed._type = FT_texture;
152 import(texture_filename, &ed, _map_dir);
160 header->add_texture(tex);
165 result = header->write_flt(dest);
166 if (result != FE_ok) {
167 nout <<
"Cannot write " << dest <<
"\n";
180 if (!copy_binary_file(source, dest)) {
186 if (!attr_filename.
exists()) {
193 cvs_add(attr_filename);
205 if (record->
is_of_type(FltFace::get_class_type())) {
207 DCAST_INTO_V(face, record);
212 }
else if (record->
is_of_type(FltExternalReference::get_class_type())) {
214 DCAST_INTO_V(ref, record);
220 int num_subfaces = record->get_num_subfaces();
221 for (i = 0; i < num_subfaces; i++) {
222 scan_flt(record->get_subface(i), refs, textures);
225 int num_children = record->get_num_children();
226 for (i = 0; i < num_children; i++) {
227 scan_flt(record->get_child(i), refs, textures);
232 int main(
int argc,
char *argv[]) {