Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

bool Agi::WagProperty::read ( Common::SeekableReadStream stream )

Read in a property (Header and data).

Returns:
True if reading was a success, false otherwise.

Definition at line 66 of file wagparser.cpp.

References _propCode, _propData, _propNum, _propSize, _propType, _readOk, deleteData(), Common::ReadStream::eos(), Common::Stream::err(), Common::ReadStream::read(), Common::ReadStream::readByte(), and Common::ReadStream::readUint16LE().

Referenced by Agi::WagFileParser::parse().

                                                       {
      // First read the property's header
      _propCode = (enum WagPropertyCode) stream.readByte();
      _propType = (enum WagPropertyType) stream.readByte();
      _propNum  = stream.readByte();
      _propSize = stream.readUint16LE();

      if (stream.eos() || stream.err()) { // Check that we got the whole header
            _readOk = false;
            return _readOk;
      }

      // Then read the property's data
      deleteData(); // Delete old data (If any)
      _propData = new char[_propSize + 1UL]; // Allocate space for property's data plus trailing zero
      uint32 readBytes = stream.read(_propData, _propSize); // Read the data in
      _propData[_propSize] = 0; // Set the trailing zero for easy C-style string access

      _readOk = (_propData != NULL && readBytes == _propSize); // Check that we got the whole data
      return _readOk;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index