Explorar el Código

refine path_replace usage

David Rose hace 23 años
padre
commit
6bfce4f544

+ 4 - 4
pandatool/src/converter/somethingToEggConverter.I

@@ -480,8 +480,8 @@ get_egg_data() {
 //     Function: SomethingToEggConverter::convert_texture_path
 //     Function: SomethingToEggConverter::convert_texture_path
 //       Access: Public
 //       Access: Public
 //  Description: Converts the indicated texture filename to a relative
 //  Description: Converts the indicated texture filename to a relative
-//               or absolute or whatever filename, according to _tpc
-//               and _tpc_directory.  See convert_path().
+//               or absolute or whatever filename, according to
+//               _path_replace.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE Filename SomethingToEggConverter::
 INLINE Filename SomethingToEggConverter::
 convert_texture_path(const Filename &orig_filename) {
 convert_texture_path(const Filename &orig_filename) {
@@ -492,8 +492,8 @@ convert_texture_path(const Filename &orig_filename) {
 //     Function: SomethingToEggConverter::convert_model_path
 //     Function: SomethingToEggConverter::convert_model_path
 //       Access: Public
 //       Access: Public
 //  Description: Converts the indicated model filename to a relative
 //  Description: Converts the indicated model filename to a relative
-//               or absolute or whatever filename, according to _mpc
-//               and _mpc_directory.  See convert_path().
+//               or absolute or whatever filename, according to
+//               _path_replace.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE Filename SomethingToEggConverter::
 INLINE Filename SomethingToEggConverter::
 convert_model_path(const Filename &orig_filename) {
 convert_model_path(const Filename &orig_filename) {

+ 5 - 10
pandatool/src/converter/somethingToEggConverter.cxx

@@ -108,21 +108,16 @@ set_egg_data(EggData *egg_data, bool owns_egg_data) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool SomethingToEggConverter::
 bool SomethingToEggConverter::
 handle_external_reference(EggGroupNode *egg_parent,
 handle_external_reference(EggGroupNode *egg_parent,
-                          const Filename &orig_filename,
-                          const DSearchPath &searchpath) {
+                          const Filename &ref_filename) {
   if (_merge_externals) {
   if (_merge_externals) {
     SomethingToEggConverter *ext = make_copy();
     SomethingToEggConverter *ext = make_copy();
     EggData egg_data;
     EggData egg_data;
     egg_data.set_coordinate_system(get_egg_data().get_coordinate_system());
     egg_data.set_coordinate_system(get_egg_data().get_coordinate_system());
     ext->set_egg_data(&egg_data, false);
     ext->set_egg_data(&egg_data, false);
 
 
-    // If we're reading references directly, we don't need to convert
-    // the pathname to something appropriate for storing, but we do
-    // need to hunt for it.
-    Filename as_found = _path_replace->match_path(orig_filename, searchpath);
-    if (!ext->convert_file(as_found)) {
+    if (!ext->convert_file(ref_filename)) {
       delete ext;
       delete ext;
-      nout << "Unable to read external reference: " << orig_filename << "\n";
+      nout << "Unable to read external reference: " << ref_filename << "\n";
       if (!_allow_errors) {
       if (!_allow_errors) {
         _error = true;
         _error = true;
       }
       }
@@ -135,8 +130,8 @@ handle_external_reference(EggGroupNode *egg_parent,
 
 
   } else {
   } else {
     // If we're installing external references instead of reading
     // If we're installing external references instead of reading
-    // them, we should massage the filename as specified.
-    Filename filename = _path_replace->convert_path(orig_filename, searchpath);
+    // them, we should make it into an egg filename.
+    Filename filename = ref_filename;
     filename.set_extension("egg");
     filename.set_extension("egg");
 
 
     EggExternalReference *egg_ref = new EggExternalReference("", filename);
     EggExternalReference *egg_ref = new EggExternalReference("", filename);

+ 1 - 2
pandatool/src/converter/somethingToEggConverter.h

@@ -105,8 +105,7 @@ public:
   virtual bool convert_file(const Filename &filename)=0;
   virtual bool convert_file(const Filename &filename)=0;
 
 
   bool handle_external_reference(EggGroupNode *egg_parent,
   bool handle_external_reference(EggGroupNode *egg_parent,
-                                 const Filename &orig_filename,
-                                 const DSearchPath &searchpath = DSearchPath());
+                                 const Filename &ref_filename);
 
 
   INLINE Filename convert_texture_path(const Filename &orig_filename);
   INLINE Filename convert_texture_path(const Filename &orig_filename);
   INLINE Filename convert_model_path(const Filename &orig_filename);
   INLINE Filename convert_model_path(const Filename &orig_filename);

+ 27 - 24
pandatool/src/flt/fltExternalReference.cxx

@@ -35,27 +35,18 @@ FltExternalReference(FltHeader *header) : FltBead(header) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: FltExternalReference::convert_paths
+//     Function: FltExternalReference::apply_converted_filenames
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Converts all of the paths referenced by this record
-//               and below according to the indicated path replace
-//               parameters.  If the resulting paths are absolute
-//               (beginning with a slash), they are converted to
-//               os-specific form before writing them out; otherwise,
-//               if they are relative, they are left in panda-specific
-//               form (under the assumption that a slash-delimited set
-//               of directory names is universally understood).
+//  Description: Walks the hierarchy at this record and below and
+//               copies the _converted_filename record into the
+//               _orig_filename record, so the flt file will be
+//               written out with the converted filename instead of
+//               what was originally read in.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FltExternalReference::
 void FltExternalReference::
-convert_paths(PathReplace *path_replace) {
-  Filename new_filename = path_replace->convert_path(get_ref_filename());
-  if (new_filename.is_local()) {
-    _filename = new_filename;
-  } else {
-    _filename = new_filename.to_os_specific();
-  }
-  
-  FltRecord::convert_paths(path_replace);
+apply_converted_filenames() {
+  _orig_filename = _converted_filename.to_os_generic();
+  FltBead::apply_converted_filenames();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -68,20 +59,31 @@ convert_paths(PathReplace *path_replace) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FltExternalReference::
 void FltExternalReference::
 output(ostream &out) const {
 output(ostream &out) const {
-  out << "External " << _filename;
+  out << "External " << get_ref_filename();
   if (!_bead_id.empty()) {
   if (!_bead_id.empty()) {
     out << " (" << _bead_id << ")";
     out << " (" << _bead_id << ")";
   }
   }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: FltTexture::get_ref_filename
+//     Function: FltExternalReference::get_ref_filename
 //       Access: Public
 //       Access: Public
 //  Description: Returns the name of the referenced file.
 //  Description: Returns the name of the referenced file.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 Filename FltExternalReference::
 Filename FltExternalReference::
 get_ref_filename() const {
 get_ref_filename() const {
-  return Filename::from_os_specific(_filename);
+  return _converted_filename;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltExternalReference::set_ref_filename
+//       Access: Public
+//  Description: Changes the name of the referenced file.
+////////////////////////////////////////////////////////////////////
+void FltExternalReference::
+set_ref_filename(const Filename &filename) {
+  _converted_filename = filename; 
+  _orig_filename = _converted_filename.to_os_generic();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -108,16 +110,17 @@ extract_record(FltRecordReader &reader) {
   iterator.skip_bytes(2);
   iterator.skip_bytes(2);
   iterator.skip_bytes(2);   // Undocumented additional padding.
   iterator.skip_bytes(2);   // Undocumented additional padding.
 
 
-  _filename = name;
+  _orig_filename = name;
 
 
   if (!name.empty() && name[name.length() - 1] == '>') {
   if (!name.empty() && name[name.length() - 1] == '>') {
     // Extract out the bead name.
     // Extract out the bead name.
     size_t open = name.rfind('<');
     size_t open = name.rfind('<');
     if (open != string::npos) {
     if (open != string::npos) {
-      _filename = name.substr(0, open);
+      _orig_filename = name.substr(0, open);
       _bead_id = name.substr(open + 1, name.length() - open - 2);
       _bead_id = name.substr(open + 1, name.length() - open - 2);
     }
     }
   }
   }
+  _converted_filename = _header->convert_path(_orig_filename);
 
 
   check_remaining_size(iterator);
   check_remaining_size(iterator);
   return true;
   return true;
@@ -140,7 +143,7 @@ build_record(FltRecordWriter &writer) const {
   writer.set_opcode(FO_external_ref);
   writer.set_opcode(FO_external_ref);
   Datagram &datagram = writer.update_datagram();
   Datagram &datagram = writer.update_datagram();
 
 
-  string name = _filename;
+  string name = _orig_filename;
   if (!_bead_id.empty()) {
   if (!_bead_id.empty()) {
     name += "<" + _bead_id + ">";
     name += "<" + _bead_id + ">";
   }
   }

+ 4 - 2
pandatool/src/flt/fltExternalReference.h

@@ -34,7 +34,7 @@ class FltExternalReference : public FltBead {
 public:
 public:
   FltExternalReference(FltHeader *header);
   FltExternalReference(FltHeader *header);
 
 
-  virtual void convert_paths(PathReplace *path_replace);
+  virtual void apply_converted_filenames();
   virtual void output(ostream &out) const;
   virtual void output(ostream &out) const;
 
 
   enum Flags {
   enum Flags {
@@ -46,11 +46,13 @@ public:
     F_light_palette_override      = 0x04000000
     F_light_palette_override      = 0x04000000
   };
   };
 
 
-  Filename _filename;
+  string _orig_filename;
+  Filename _converted_filename;
   string _bead_id;
   string _bead_id;
   int _flags;
   int _flags;
 
 
   Filename get_ref_filename() const;
   Filename get_ref_filename() const;
+  void set_ref_filename(const Filename &filename);
 
 
 protected:
 protected:
   virtual bool extract_record(FltRecordReader &reader);
   virtual bool extract_record(FltRecordReader &reader);

+ 118 - 3
pandatool/src/flt/fltHeader.cxx

@@ -22,7 +22,7 @@
 #include "fltUnsupportedRecord.h"
 #include "fltUnsupportedRecord.h"
 #include "config_flt.h"
 #include "config_flt.h"
 
 
-#include <nearly_zero.h>
+#include "nearly_zero.h"
 
 
 #include <assert.h>
 #include <assert.h>
 #include <math.h>
 #include <math.h>
@@ -32,10 +32,27 @@ TypeHandle FltHeader::_type_handle;
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: FltHeader::Constructor
 //     Function: FltHeader::Constructor
 //       Access: Public
 //       Access: Public
-//  Description:
+//  Description: The FltHeader constructor accepts a PathReplace
+//               pointer; it uses this object to automatically convert
+//               all external filename and texture references.  (This
+//               is necessary because the FltHeader has to look in the
+//               same directory as the texture to find the .attr file,
+//               so it must pre-convert at least the texture
+//               references.)
+//
+//               Most of the other file converters do not have this
+//               requirement, so they do not need to pre-convert any
+//               pathname references.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 FltHeader::
 FltHeader::
-FltHeader() : FltBeadID(this) {
+FltHeader(PathReplace *path_replace) : FltBeadID(this) {
+  if (path_replace == (PathReplace *)NULL) {
+    _path_replace = new PathReplace;
+    _path_replace->_path_store = PS_absolute;
+  } else {
+    _path_replace = path_replace;
+  }
+
   _format_revision_level = 1570;
   _format_revision_level = 1570;
   _edit_revision_level = 1570;
   _edit_revision_level = 1570;
   _next_group_id = 1;
   _next_group_id = 1;
@@ -91,7 +108,104 @@ FltHeader() : FltBeadID(this) {
   _got_eyepoint_trackplane_palette = false;
   _got_eyepoint_trackplane_palette = false;
 
 
   _auto_attr_update = AU_if_missing;
   _auto_attr_update = AU_if_missing;
+}
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::apply_converted_filenames
+//       Access: Public, Virtual
+//  Description: Walks the hierarchy at this record and below and
+//               copies the _converted_filename record into the
+//               _orig_filename record, so the flt file will be
+//               written out with the converted filename instead of
+//               what was originally read in.
+////////////////////////////////////////////////////////////////////
+void FltHeader::
+apply_converted_filenames() {
+  Textures::const_iterator ti;
+  for (ti = _textures.begin(); ti != _textures.end(); ++ti) {
+    FltTexture *texture = (*ti).second;
+    texture->apply_converted_filenames();
+  }
+
+  FltBeadID::apply_converted_filenames();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::set_path_replace
+//       Access: Public
+//  Description: Replaces the PathReplace object (which specifies how
+//               to mangle paths from the source to the destination
+//               file) with a new one.
+////////////////////////////////////////////////////////////////////
+void FltHeader::
+set_path_replace(PathReplace *path_replace) {
+  _path_replace = path_replace;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::get_path_replace
+//       Access: Public
+//  Description: Returns a pointer to the PathReplace object
+//               associated with this converter.  If the converter is
+//               non-const, this returns a non-const pointer, which
+//               can be adjusted.
+////////////////////////////////////////////////////////////////////
+PathReplace *FltHeader::
+get_path_replace() {
+  return _path_replace;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::get_path_replace
+//       Access: Public
+//  Description: Returns a pointer to the PathReplace object
+//               associated with this converter.  If the converter is
+//               non-const, this returns a non-const pointer, which
+//               can be adjusted.
+////////////////////////////////////////////////////////////////////
+const PathReplace *FltHeader::
+get_path_replace() const {
+  return _path_replace;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::convert_path
+//       Access: Public
+//  Description: Uses the PathReplace object to convert the named
+//               filename as read from the flt record to its actual
+//               name.
+////////////////////////////////////////////////////////////////////
+Filename FltHeader::
+convert_path(const Filename &orig_filename, const DSearchPath &additional_path) {
+  DSearchPath file_path;
+  if (!_flt_filename.empty()) {
+    file_path.append_directory(_flt_filename.get_dirname());
+  }
+  file_path.append_path(additional_path);
+  return _path_replace->convert_path(orig_filename, file_path);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::set_flt_filename
+//       Access: Public
+//  Description: Sets the filename--especially the directory part--in
+//               which the flt file is considered to reside.  This is
+//               also implicitly set by read_flt().
+////////////////////////////////////////////////////////////////////
+void FltHeader::
+set_flt_filename(const Filename &flt_filename) {
+  _flt_filename = flt_filename;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltHeader::get_flt_filename
+//       Access: Public
+//  Description: Returns the directory in which the flt file is
+//               considered to reside.
+////////////////////////////////////////////////////////////////////
+const Filename &FltHeader::
+get_flt_filename() const {
+  return _flt_filename;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -104,6 +218,7 @@ FltHeader() : FltBeadID(this) {
 FltError FltHeader::
 FltError FltHeader::
 read_flt(Filename filename) {
 read_flt(Filename filename) {
   filename.set_binary();
   filename.set_binary();
+  _flt_filename = filename;
 
 
   ifstream in;
   ifstream in;
   if (!filename.open_read(in)) {
   if (!filename.open_read(in)) {

+ 17 - 1
pandatool/src/flt/fltHeader.h

@@ -30,6 +30,8 @@
 #include "fltTrackplane.h"
 #include "fltTrackplane.h"
 #include "fltInstanceDefinition.h"
 #include "fltInstanceDefinition.h"
 
 
+#include "pathReplace.h"
+#include "pointerTo.h"
 #include "filename.h"
 #include "filename.h"
 #include "dSearchPath.h"
 #include "dSearchPath.h"
 #include "distanceUnit.h"
 #include "distanceUnit.h"
@@ -49,7 +51,18 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 class FltHeader : public FltBeadID {
 class FltHeader : public FltBeadID {
 public:
 public:
-  FltHeader();
+  FltHeader(PathReplace *path_replace);
+
+  virtual void apply_converted_filenames();
+
+  void set_path_replace(PathReplace *path_replace);
+  PathReplace *get_path_replace();
+  const PathReplace *get_path_replace() const;
+  Filename convert_path(const Filename &orig_filename,
+			const DSearchPath &additional_path = DSearchPath());
+
+  void set_flt_filename(const Filename &flt_filename);
+  const Filename &get_flt_filename() const;
 
 
   FltError read_flt(Filename filename);
   FltError read_flt(Filename filename);
   FltError read_flt(istream &in);
   FltError read_flt(istream &in);
@@ -284,6 +297,9 @@ private:
   FltEyepoint _eyepoints[10];
   FltEyepoint _eyepoints[10];
   FltTrackplane _trackplanes[10];
   FltTrackplane _trackplanes[10];
 
 
+  // This pointer is used to resolve references in the flt file.
+  PT(PathReplace) _path_replace;
+  Filename _flt_filename;
 
 
 protected:
 protected:
   virtual bool extract_record(FltRecordReader &reader);
   virtual bool extract_record(FltRecordReader &reader);

+ 9 - 12
pandatool/src/flt/fltRecord.cxx

@@ -331,25 +331,22 @@ check_remaining_size(const DatagramIterator &di, const string &name) const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: FltRecord::convert_paths
+//     Function: FltRecord::apply_converted_filenames
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Converts all of the paths referenced by this record
-//               and below according to the indicated path replace
-//               parameters.  If the resulting paths are absolute
-//               (beginning with a slash), they are converted to
-//               os-specific form before writing them out; otherwise,
-//               if they are relative, they are left in panda-specific
-//               form (under the assumption that a slash-delimited set
-//               of directory names is universally understood).
+//  Description: Walks the hierarchy at this record and below and
+//               copies the _converted_filename record into the
+//               _orig_filename record, so the flt file will be
+//               written out with the converted filename instead of
+//               what was originally read in.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FltRecord::
 void FltRecord::
-convert_paths(PathReplace *path_replace) {
+apply_converted_filenames() {
   Records::const_iterator ci;
   Records::const_iterator ci;
   for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
   for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) {
-    (*ci)->convert_paths(path_replace);
+    (*ci)->apply_converted_filenames();
   }
   }
   for (ci = _children.begin(); ci != _children.end(); ++ci) {
   for (ci = _children.begin(); ci != _children.end(); ++ci) {
-    (*ci)->convert_paths(path_replace);
+    (*ci)->apply_converted_filenames();
   }
   }
 }
 }
 
 

+ 1 - 2
pandatool/src/flt/fltRecord.h

@@ -32,7 +32,6 @@ class FltHeader;
 class FltRecordReader;
 class FltRecordReader;
 class FltRecordWriter;
 class FltRecordWriter;
 class DatagramIterator;
 class DatagramIterator;
-class PathReplace;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : FltRecord
 //       Class : FltRecord
@@ -75,7 +74,7 @@ public:
   void check_remaining_size(const DatagramIterator &di, 
   void check_remaining_size(const DatagramIterator &di, 
                             const string &name = string()) const;
                             const string &name = string()) const;
 
 
-  virtual void convert_paths(PathReplace *path_replace);
+  virtual void apply_converted_filenames();
 
 
   virtual void output(ostream &out) const;
   virtual void output(ostream &out) const;
   virtual void write(ostream &out, int indent_level = 0) const;
   virtual void write(ostream &out, int indent_level = 0) const;

+ 26 - 22
pandatool/src/flt/fltTexture.cxx

@@ -21,6 +21,7 @@
 #include "fltRecordWriter.h"
 #include "fltRecordWriter.h"
 #include "fltHeader.h"
 #include "fltHeader.h"
 #include "pathReplace.h"
 #include "pathReplace.h"
+#include "config_util.h"
 
 
 TypeHandle FltTexture::_type_handle;
 TypeHandle FltTexture::_type_handle;
 
 
@@ -89,27 +90,18 @@ FltTexture(FltHeader *header) : FltRecord(header) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: FltTexture::convert_paths
+//     Function: FltTexture::apply_converted_filenames
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Converts all of the paths referenced by this record
-//               and below according to the indicated path replace
-//               parameters.  If the resulting paths are absolute
-//               (beginning with a slash), they are converted to
-//               os-specific form before writing them out; otherwise,
-//               if they are relative, they are left in panda-specific
-//               form (under the assumption that a slash-delimited set
-//               of directory names is universally understood).
+//  Description: Walks the hierarchy at this record and below and
+//               copies the _converted_filename record into the
+//               _orig_filename record, so the flt file will be
+//               written out with the converted filename instead of
+//               what was originally read in.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FltTexture::
 void FltTexture::
-convert_paths(PathReplace *path_replace) {
-  Filename new_filename = path_replace->convert_path(get_texture_filename());
-  if (new_filename.is_local()) {
-    _filename = new_filename;
-  } else {
-    _filename = new_filename.to_os_specific();
-  }
-  
-  FltRecord::convert_paths(path_replace);
+apply_converted_filenames() {
+  _orig_filename = _converted_filename.to_os_generic();
+  FltRecord::apply_converted_filenames();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -119,7 +111,18 @@ convert_paths(PathReplace *path_replace) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 Filename FltTexture::
 Filename FltTexture::
 get_texture_filename() const {
 get_texture_filename() const {
-  return Filename::from_os_specific(_filename);
+  return _converted_filename;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: FltTexture::set_texture_filename
+//       Access: Public
+//  Description: Changes the name of the texture image file.
+////////////////////////////////////////////////////////////////////
+void FltTexture::
+set_texture_filename(const Filename &filename) {
+  _converted_filename = filename; 
+  _orig_filename = _converted_filename.to_os_generic();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -239,10 +242,11 @@ extract_record(FltRecordReader &reader) {
   DatagramIterator &iterator = reader.get_iterator();
   DatagramIterator &iterator = reader.get_iterator();
 
 
   if (_header->get_flt_version() < 1420) {
   if (_header->get_flt_version() < 1420) {
-    _filename = iterator.get_fixed_string(80);
+    _orig_filename = iterator.get_fixed_string(80);
   } else {
   } else {
-    _filename = iterator.get_fixed_string(200);
+    _orig_filename = iterator.get_fixed_string(200);
   }
   }
+  _converted_filename = _header->convert_path(_orig_filename, get_texture_path());
   _pattern_index = iterator.get_be_int32();
   _pattern_index = iterator.get_be_int32();
   _x_location = iterator.get_be_int32();
   _x_location = iterator.get_be_int32();
   _y_location = iterator.get_be_int32();
   _y_location = iterator.get_be_int32();
@@ -272,7 +276,7 @@ build_record(FltRecordWriter &writer) const {
   writer.set_opcode(FO_texture);
   writer.set_opcode(FO_texture);
   Datagram &datagram = writer.update_datagram();
   Datagram &datagram = writer.update_datagram();
 
 
-  datagram.add_fixed_string(_filename, 200);
+  datagram.add_fixed_string(_orig_filename, 200);
   datagram.add_be_int32(_pattern_index);
   datagram.add_be_int32(_pattern_index);
   datagram.add_be_int32(_x_location);
   datagram.add_be_int32(_x_location);
   datagram.add_be_int32(_y_location);
   datagram.add_be_int32(_y_location);

+ 7 - 5
pandatool/src/flt/fltTexture.h

@@ -19,12 +19,12 @@
 #ifndef FLTTEXTURE_H
 #ifndef FLTTEXTURE_H
 #define FLTTEXTURE_H
 #define FLTTEXTURE_H
 
 
-#include <pandatoolbase.h>
+#include "pandatoolbase.h"
 
 
 #include "fltRecord.h"
 #include "fltRecord.h"
 
 
-#include <filename.h>
-#include <luse.h>
+#include "filename.h"
+#include "luse.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : FltTexture
 //       Class : FltTexture
@@ -34,14 +34,16 @@ class FltTexture : public FltRecord {
 public:
 public:
   FltTexture(FltHeader *header);
   FltTexture(FltHeader *header);
 
 
-  virtual void convert_paths(PathReplace *path_replace);
+  virtual void apply_converted_filenames();
 
 
-  string _filename;
+  string _orig_filename;
+  Filename _converted_filename;
   int _pattern_index;
   int _pattern_index;
   int _x_location;
   int _x_location;
   int _y_location;
   int _y_location;
 
 
   Filename get_texture_filename() const;
   Filename get_texture_filename() const;
+  void set_texture_filename(const Filename &filename);
   Filename get_attr_filename() const;
   Filename get_attr_filename() const;
   FltError read_attr_data();
   FltError read_attr_data();
   FltError write_attr_data() const;
   FltError write_attr_data() const;

+ 4 - 3
pandatool/src/fltegg/fltToEggConverter.cxx

@@ -120,7 +120,7 @@ get_extension() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool FltToEggConverter::
 bool FltToEggConverter::
 convert_file(const Filename &filename) {
 convert_file(const Filename &filename) {
-  PT(FltHeader) header = new FltHeader;
+  PT(FltHeader) header = new FltHeader(_path_replace);
 
 
   nout << "Reading " << filename << "\n";
   nout << "Reading " << filename << "\n";
   FltError result = header->read_flt(filename);
   FltError result = header->read_flt(filename);
@@ -619,7 +619,8 @@ parse_comment(const FltBead *flt_bead, EggNode *egg_node) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool FltToEggConverter::
 bool FltToEggConverter::
 parse_comment(const FltTexture *flt_texture, EggNode *egg_node) {
 parse_comment(const FltTexture *flt_texture, EggNode *egg_node) {
-  return parse_comment(flt_texture->_comment, flt_texture->_filename, egg_node);
+  return parse_comment(flt_texture->get_comment(), 
+		       flt_texture->get_texture_filename(), egg_node);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -744,7 +745,7 @@ make_egg_texture(const FltTexture *flt_texture) {
 
 
   // Create a new one.
   // Create a new one.
   string tref_name = format_string(flt_texture->_pattern_index);
   string tref_name = format_string(flt_texture->_pattern_index);
-  Filename filename = convert_texture_path(flt_texture->get_texture_filename());
+  Filename filename = flt_texture->get_texture_filename();
 
 
   PT_EggTexture egg_texture = new EggTexture(tref_name, filename);
   PT_EggTexture egg_texture = new EggTexture(tref_name, filename);
 
 

+ 7 - 9
pandatool/src/fltprogs/fltCopy.cxx

@@ -110,7 +110,7 @@ copy_file(const Filename &source, const Filename &dest,
 bool FltCopy::
 bool FltCopy::
 copy_flt_file(const Filename &source, const Filename &dest,
 copy_flt_file(const Filename &source, const Filename &dest,
               CVSSourceDirectory *dir) {
               CVSSourceDirectory *dir) {
-  PT(FltHeader) header = new FltHeader;
+  PT(FltHeader) header = new FltHeader(_path_replace);
 
 
   // We don't want to automatically generate .attr files--we'd rather
   // We don't want to automatically generate .attr files--we'd rather
   // write them out explicitly.
   // write them out explicitly.
@@ -132,8 +132,7 @@ copy_flt_file(const Filename &source, const Filename &dest,
   Refs::const_iterator ri;
   Refs::const_iterator ri;
   for (ri = refs.begin(); ri != refs.end(); ++ri) {
   for (ri = refs.begin(); ri != refs.end(); ++ri) {
     FltExternalReference *ref = (*ri);
     FltExternalReference *ref = (*ri);
-    Filename ref_filename = 
-      _path_replace->convert_path(ref->get_ref_filename());
+    Filename ref_filename = ref->get_ref_filename();
 
 
     if (!ref_filename.exists()) {
     if (!ref_filename.exists()) {
       nout << "*** Warning: external reference " << ref_filename
       nout << "*** Warning: external reference " << ref_filename
@@ -150,8 +149,8 @@ copy_flt_file(const Filename &source, const Filename &dest,
 
 
       // Update the reference to point to the new flt filename, relative
       // Update the reference to point to the new flt filename, relative
       // to the base flt file.
       // to the base flt file.
-      ref->_filename = dir->get_rel_to(ref_dir) + "/" +
-        ref_filename.get_basename();
+      ref->set_ref_filename(dir->get_rel_to(ref_dir) + "/" +
+			    ref_filename.get_basename());
     }
     }
   }
   }
 
 
@@ -163,8 +162,7 @@ copy_flt_file(const Filename &source, const Filename &dest,
   Textures::const_iterator ti;
   Textures::const_iterator ti;
   for (ti = textures.begin(); ti != textures.end(); ++ti) {
   for (ti = textures.begin(); ti != textures.end(); ++ti) {
     FltTexture *tex = (*ti);
     FltTexture *tex = (*ti);
-    Filename texture_filename = 
-      _path_replace->convert_path(tex->get_texture_filename());
+    Filename texture_filename = tex->get_texture_filename();
 
 
     if (!texture_filename.exists()) {
     if (!texture_filename.exists()) {
       nout << "*** Warning: texture " << texture_filename
       nout << "*** Warning: texture " << texture_filename
@@ -182,8 +180,8 @@ copy_flt_file(const Filename &source, const Filename &dest,
 
 
       // Update the texture reference to point to the new texture
       // Update the texture reference to point to the new texture
       // filename, relative to the flt file.
       // filename, relative to the flt file.
-      tex->_filename = dir->get_rel_to(texture_dir) + "/" +
-        texture_filename.get_basename();
+      tex->set_texture_filename(dir->get_rel_to(texture_dir) + "/" +
+				texture_filename.get_basename());
       header->add_texture(tex);
       header->add_texture(tex);
     }
     }
   }
   }

+ 1 - 1
pandatool/src/fltprogs/fltInfo.cxx

@@ -49,7 +49,7 @@ FltInfo() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FltInfo::
 void FltInfo::
 run() {
 run() {
-  PT(FltHeader) header = new FltHeader;
+  PT(FltHeader) header = new FltHeader(_path_replace);
 
 
   nout << "Reading " << _input_filename << "\n";
   nout << "Reading " << _input_filename << "\n";
   FltError result = header->read_flt(_input_filename);
   FltError result = header->read_flt(_input_filename);

+ 1 - 1
pandatool/src/fltprogs/fltToEgg.cxx

@@ -68,7 +68,7 @@ FltToEgg() :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FltToEgg::
 void FltToEgg::
 run() {
 run() {
-  PT(FltHeader) header = new FltHeader;
+  PT(FltHeader) header = new FltHeader(_path_replace);
 
 
   nout << "Reading " << _input_filename << "\n";
   nout << "Reading " << _input_filename << "\n";
   FltError result = header->read_flt(_input_filename);
   FltError result = header->read_flt(_input_filename);

+ 2 - 2
pandatool/src/fltprogs/fltTrans.cxx

@@ -79,7 +79,7 @@ run() {
     }
     }
   }
   }
 
 
-  PT(FltHeader) header = new FltHeader;
+  PT(FltHeader) header = new FltHeader(_path_replace);
 
 
   nout << "Reading " << _input_filename << "\n";
   nout << "Reading " << _input_filename << "\n";
   FltError result = header->read_flt(_input_filename);
   FltError result = header->read_flt(_input_filename);
@@ -97,7 +97,7 @@ run() {
     header->set_flt_version(new_version);
     header->set_flt_version(new_version);
   }
   }
 
 
-  header->convert_paths(_path_replace);
+  header->apply_converted_filenames();
 
 
   result = header->write_flt(get_output());
   result = header->write_flt(get_output());
   if (result != FE_ok) {
   if (result != FE_ok) {