1
0
Fork 0

addon-metadata.xml: add meta section (non-leaf node) and file-type node

Move the format-version node inside /meta. It's not compatible of
course, but since the stuff this is breaking is only 2 or 3 days old,
let's go for it for nicer code and file format.

Sorry if you had already written an addon-metadata.xml file of your
own. In this case, just replace:

  <format-version type="int">1</format-version>

with:

  <meta>
    <file-type type="string">FlightGear add-on metadata</file-type>
    <format-version type="int">1</format-version>
  </meta>
This commit is contained in:
Florent Rougon 2017-12-10 19:20:49 +01:00
parent 88940eb6bc
commit 45867058f0

View file

@ -140,11 +140,35 @@ AddonManager::registerAddonMetadata(const SGPath& addonPath)
e.getFormattedMessage());
}
// Check the format version of the metadata file
SGPropertyNode *fmtVersionNode = addonRoot.getChild("format-version");
// Check the 'meta' section
SGPropertyNode *metaNode = addonRoot.getChild("meta");
if (metaNode == nullptr) {
throw addon_errors::error_loading_metadata_file(
"no /meta node found in add-on metadata file '" +
metadataFile.utf8Str() + "'");
}
// Check the file type
SGPropertyNode *fileTypeNode = metaNode->getChild("file-type");
if (fileTypeNode == nullptr) {
throw addon_errors::error_loading_metadata_file(
"no /meta/file-type node found in add-on metadata file '" +
metadataFile.utf8Str() + "'");
}
string fileType = fileTypeNode->getStringValue();
if (fileType != "FlightGear add-on metadata") {
throw addon_errors::error_loading_metadata_file(
"Invalid /meta/file-type value for add-on metadata file '" +
metadataFile.utf8Str() + "': '" + fileType + "' "
"(expected 'FlightGear add-on metadata')");
}
// Check the format version
SGPropertyNode *fmtVersionNode = metaNode->getChild("format-version");
if (fmtVersionNode == nullptr) {
throw addon_errors::error_loading_metadata_file(
"no 'format-version' node found in add-on metadata file '" +
"no /meta/format-version node found in add-on metadata file '" +
metadataFile.utf8Str() + "'");
}