15 #include "iffInputFile.h" 16 #include "iffGenericChunk.h" 18 #include "datagramIterator.h" 19 #include "virtualFileSystem.h" 30 _input = (istream *)NULL;
31 _owns_istream =
false;
33 _unexpected_eof =
false;
62 if (in == (istream *)NULL) {
87 _owns_istream = owns_istream;
89 _unexpected_eof =
false;
230 const char *
id = (
const char *)dg.
get_data();
253 PT(
IffChunk) chunk = make_new_chunk(
id);
257 size_t end_point = start_point + length;
259 if (chunk->read_iff(
this, end_point)) {
261 if (!_unexpected_eof) {
262 nout <<
"Unexpected EOF on file reading " << *chunk <<
"\n";
263 _unexpected_eof =
true;
269 if (num_bytes_read > length) {
270 nout << *chunk <<
" read " << num_bytes_read
271 <<
" instead of " << length <<
" bytes.\n";
274 }
else if (num_bytes_read < length) {
275 size_t skip_count = length - num_bytes_read;
276 nout <<
"Ignoring " << skip_count <<
" bytes at the end of " 311 size_t end_point = start_point + length;
313 if (chunk->read_iff(
this, end_point)) {
315 if (!_unexpected_eof) {
316 nout <<
"Unexpected EOF on file reading " << *chunk <<
"\n";
317 _unexpected_eof =
true;
323 if (num_bytes_read > length) {
324 nout << *chunk <<
" read " << num_bytes_read
325 <<
" instead of " << length <<
" bytes.\n";
328 }
else if (num_bytes_read < length) {
329 size_t skip_count = length - num_bytes_read;
330 nout <<
"Ignoring " << skip_count <<
" bytes at the end of " 355 _eof = _input->eof() || _input->fail();
372 char *buffer =
new char[length];
373 _input->read(buffer, length);
374 _eof = (_input->gcount() != length);
379 _bytes_read += length;
380 datagram =
Datagram(buffer, length);
398 while (length > 0 && !
is_eof()) {
413 make_new_chunk(
IffId) {
PN_int8 get_int8()
Extracts a signed 8-bit integer.
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
istream * open_read_file(const Filename &filename, bool auto_unwrap) const
Convenience function; returns a newly allocated istream if the file exists and can be read...
virtual IffChunk * make_new_chunk(IffInputFile *in, IffId id)
Allocates and returns a new chunk of the appropriate type based on the given ID, according to the con...
void set_binary()
Indicates that the filename represents a binary file.
PN_float32 get_be_float32()
Extracts a 32-bit big-endian single-precision floating-point number.
static void close_read_file(istream *stream)
Closes a file opened by a previous call to open_read_file().
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on...
The name of a file, such as a texture file or an Egg file.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
PN_uint32 get_be_uint32()
Extracts an unsigned 32-bit big-endian integer.
PN_int16 get_be_int16()
Extracts a signed 16-bit big-endian integer.
void set_id(IffId id)
Changes the ID associated with this chunk.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
A four-byte chunk ID appearing in an "IFF" file.
PN_uint16 get_be_uint16()
Extracts an unsigned 16-bit big-endian integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PN_int32 get_be_int32()
Extracts a signed 32-bit big-endian integer.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.
A class for a generic kind of IffChunk that is not understood by a particular IffReader.