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:
parent
88940eb6bc
commit
45867058f0
1 changed files with 27 additions and 3 deletions
|
@ -140,11 +140,35 @@ AddonManager::registerAddonMetadata(const SGPath& addonPath)
|
||||||
e.getFormattedMessage());
|
e.getFormattedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the format version of the metadata file
|
// Check the 'meta' section
|
||||||
SGPropertyNode *fmtVersionNode = addonRoot.getChild("format-version");
|
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) {
|
if (fmtVersionNode == nullptr) {
|
||||||
throw addon_errors::error_loading_metadata_file(
|
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() + "'");
|
metadataFile.utf8Str() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue