15 #include "fltExternalReference.h" 16 #include "fltRecordReader.h" 17 #include "fltRecordWriter.h" 18 #include "fltHeader.h" 19 #include "pathReplace.h" 28 FltExternalReference::
59 if (!_bead_id.empty()) {
60 out <<
" (" << _bead_id <<
")";
71 return _converted_filename;
81 _converted_filename = filename;
93 bool FltExternalReference::
95 if (!FltBead::extract_record(reader)) {
99 nassertr(reader.
get_opcode() == FO_external_ref,
false);
103 iterator.skip_bytes(1 + 1);
104 iterator.skip_bytes(2);
105 _flags = iterator.get_be_uint32();
106 iterator.skip_bytes(2);
107 iterator.skip_bytes(2);
109 _orig_filename = name;
111 if (!name.empty() && name[name.length() - 1] ==
'>') {
113 size_t open = name.rfind(
'<');
114 if (open != string::npos) {
115 _orig_filename = name.substr(0, open);
116 _bead_id = name.substr(open + 1, name.length() - open - 2);
133 bool FltExternalReference::
135 if (!FltBead::build_record(writer)) {
142 string name = _orig_filename;
143 if (!_bead_id.empty()) {
144 name +=
"<" + _bead_id +
">";
virtual void output(ostream &out) const
Writes a quick one-line description of the record, but not its children.
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly...
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
virtual void apply_converted_filenames()
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig...
virtual void apply_converted_filenames()
Walks the hierarchy at this record and below and copies the _converted_filename record into the _orig...
void check_remaining_size(const DatagramIterator &di, const string &name=string()) const
Checks that the iterator has no bytes left, as it should at the end of a successfully read record...
void set_ref_filename(const Filename &filename)
Changes the name of the referenced file.
A base class for any of a broad family of flt records that represent particular beads in the hierarch...
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
string to_os_generic() const
This is similar to to_os_specific(), but it is designed to generate a filename that can be understood...
The name of a file, such as a texture file or an Egg file.
Filename get_ref_filename() const
Returns the name of the referenced file.
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
void add_fixed_string(const string &str, size_t size)
Adds a fixed-length string to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram. ...
void add_be_uint32(PN_uint32 value)
Adds an unsigned 32-bit big-endian integer to the datagram.
TypeHandle is the identifier used to differentiate C++ class types.
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
string get_fixed_string(size_t size)
Extracts a fixed-length string.
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).