/// <summary> /// Given that s is a .package path this will return the list of files /// for that package after recursively expanding that .package file. /// </summary> /// <param name="referencingFile"> /// The package where this the assetFile is referenced. /// </param> /// <param name="packageFile"> /// A .package file. /// </param> /// <param name="packages"> /// The set of packages being processed. /// </param> /// <returns> /// List of assets for the package s, where every .package has been expanded. /// </returns> private static IEnumerable<string> ExpandPackage( string referencingFile, string packageFile, Packages packages, HashSet<string> alreadyExpanded, ErrorReporting reporting) { // Have 2 cases: // case 1: packages contains reference. // case 2: packages DOES NOT contain reference. if (packages.ContainsKey(packageFile)) { if (alreadyExpanded.Contains(packageFile)) { reporting.AddError( string.Format( "Already included package:" + "\n\t{0} and including it again would cause infinite recursion." + "\n\tNo further expansion done.", packageFile)); return new List<string>(); } else { alreadyExpanded.Add(packageFile); return ExpandAssets(packageFile, packages, alreadyExpanded, reporting); } } else { reporting.AddWarning( string.Format( "Could not find package: {0}, as referenced in {1}", packageFile, referencingFile)); return new List<string>(); } }
/// <summary> /// Reads the given file from disk if it exists, otherwise it logs an error, /// and returns an empty string. /// </summary> /// <param name="filename"> /// Path to a text file containing an asset's text. /// </param> /// <param name="reporting"> /// Error collecting class. /// </param> /// <returns> /// The contents of the file, or empty string. /// </returns> private string ReadContent(string filename, ErrorReporting reporting) { if (File.Exists(filename)) { return File.ReadAllText(filename); } var fn = Resolver.ResolvePath(filename); if (File.Exists(fn)) { return File.ReadAllText(fn); } // Have a filename that doesn't exist, so we log it as an error. reporting.AddError( string.Format("Could not find file: {0}", filename)); return ""; }