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

bool Agi::WagFileParser::parse ( const Common::FSNode node )

Loads a *.wag file and parses it.

After this you can access the loaded properties using getProperty() and getProperties() etc.
filenameName of the file to be parsed.
True if parsed successfully, false otherwise.

Definition at line 178 of file wagparser.cpp.

References _parsedOk, _propList, checkWagVersion(), Common::FSNode::createReadStream(), endOfProperties(), Agi::WagProperty::getCode(), Common::FSNode::getPath(), Common::Array< T >::push_back(), Agi::WagProperty::read(), and Common::SeekableReadStream::seek().

Referenced by AgiMetaEngine::fallbackDetect().

      WagProperty property; // Temporary property used for reading
      Common::SeekableReadStream *stream = NULL; // The file stream

      _parsedOk = false; // We haven't parsed the file yet

      stream = node.createReadStream(); // Open the file
      if (stream) { // Check that opening the file was succesful
            if (checkWagVersion(*stream)) { // Check that WinAGI version string is valid
                  // It seems we've got a valid *.wag file so let's parse its properties from the start.
                  stream->seek(0); // Rewind the stream
                  if (!_propList.empty()) _propList.clear(); // Clear out old properties (If any)

                  do { // Parse the properties
                        if (property.read(*stream)) { // Read the property and check it was read ok
                              _propList.push_back(property); // Add read property to properties list
                              debug(4, "WagFileParser::parse: Read property with code %d, type %d, number %d, size %d, data \"%s\"",
                                    property.getCode(), property.getType(), property.getNumber(), property.getSize(), property.getData());
                        } else // Reading failed, let's bail out
                  } while (!endOfProperties(*stream)); // Loop until the end of properties

                  // File was parsed successfully only if we got to the end of properties
                  // and all the properties were read successfully (Also the last).
                  _parsedOk = endOfProperties(*stream) && property.readOk();

                  if (!_parsedOk) // Error parsing stream
                        warning("Error parsing WAG file (%s). WAG file ignored", node.getPath().c_str());
            } else // Invalid WinAGI version string or it couldn't be read
                  warning("Invalid WAG file (%s) version or error reading it. WAG file ignored", node.getPath().c_str());
      } else // Couldn't open file
            warning("Couldn't open WAG file (%s). WAG file ignored", node.getPath().c_str());

      delete stream;
      return _parsedOk;

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