/* * All or portions of this file Copyright(c) Amazon.com, Inc.or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution(the "License").All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file.Do not * remove or modify any license notices.This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include "XmlFormattedAssetBuilderWorker.h" #include namespace CopyDependencyBuilder { XmlFormattedAssetBuilderWorker::XmlFormattedAssetBuilderWorker(AZStd::string jobKey, bool critical, bool skipServer) : CopyDependencyBuilderWorker(jobKey, critical, skipServer) { } bool XmlFormattedAssetBuilderWorker::ParseProductDependencies( const AssetBuilderSDK::ProcessJobRequest& request, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& pathDependencies) { AZ::IO::FileIOStream fileStream; if (!fileStream.Open(request.m_fullPath.c_str(), AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeBinary)) { return false; } AZ::IO::SizeType length = fileStream.GetLength(); if (length == 0) { return false; } AZStd::vector charBuffer; charBuffer.resize_no_construct(length + 1); fileStream.Read(length, charBuffer.data()); charBuffer.back() = 0; // Get the XML root node AZ::rapidxml::xml_document xmlDoc; if (!xmlDoc.parse(charBuffer.data())) { return false; } AZ::rapidxml::xml_node* xmlRootNode = xmlDoc.first_node(); return xmlRootNode && ParseXmlFile(xmlRootNode, request.m_fullPath, request.m_sourceFile, request.m_platformInfo.m_identifier, productDependencies, pathDependencies); } bool XmlFormattedAssetBuilderWorker::ParseXmlFile( const AZ::rapidxml::xml_node* node, const AZStd::string& fullPath, const AZStd::string& sourceFile, const AZStd::string& platformIdentifier, AZStd::vector& productDependencies, AssetBuilderSDK::ProductPathDependencySet& productPathDependencies) { if (!node) { return false; } AddProductDependencies(node, fullPath, sourceFile, platformIdentifier, productDependencies, productPathDependencies); // Check all the child nodes for (AZ::rapidxml::xml_node* childNode = node->first_node(); childNode; childNode = childNode->next_sibling()) { if (!ParseXmlFile(childNode, fullPath, sourceFile, platformIdentifier, productDependencies, productPathDependencies)) { return false; } } return true; } }