public static void GetFilesReferencedByAsset(string fileName, TopLevelOrRecursive topLevelOrRecursive, List <string> referencedFiles) { List <string> newReferencedFiles = new List <string>(); if (!CanFileReferenceOtherFiles(fileName)) { return; } else if (!FileManager.FileExists(fileName)) { throw new FileNotFoundException("Could not find file " + fileName, fileName); } else { string fileExtension = FileManager.GetExtension(fileName); switch (fileExtension) { #region Scene (.scnx) case "scnx": SceneSave ses = SceneSave.FromFile(fileName); try { newReferencedFiles = ses.GetReferencedFiles(RelativeType.Absolute); } catch (InvalidOperationException e) { MessageBox.Show("There is an invalid file reference in the file\n\n" + fileName + "\n\nGlue will skip this file. You should investigate this file in a text editor " + "to identify the issue.\n\nAdditional error information:\n\n" + e.ToString()); } break; #endregion #region Emitter List (.emix) case "emix": EmitterSaveList esl = EmitterSaveList.FromFile(fileName); newReferencedFiles = esl.GetReferencedFiles(RelativeType.Absolute); break; #endregion #region AnimationChain List case "achx": AnimationChainListSave acls = AnimationChainListSave.FromFile(fileName); newReferencedFiles = acls.GetReferencedFiles(RelativeType.Absolute); break; #endregion #region X File (.x) case "x": newReferencedFiles = GetTextureReferencesInX(fileName); break; #endregion #region Spline List (.slpx) - falls to default case "splx": #endregion #region Font File (.fnt) case "fnt": newReferencedFiles = GetTextureReferencesInFnt(fileName); break; #endregion default: break; } // We still want to construct as good of a reference structure as possible // even if there are missing files. Therefore, we'll just keep track of errors and report them // at the end of the method bool didErrorOccur = false; string errorMessage = ""; if (topLevelOrRecursive == TopLevelOrRecursive.Recursive) { for (int i = newReferencedFiles.Count - 1; i > -1; i--) { // If this file can't reference other files, no need to even do a file check or throw errors. if (CanFileReferenceOtherFiles(newReferencedFiles[i]) == true) { if (File.Exists(newReferencedFiles[i])) { try { GetFilesReferencedByAsset(newReferencedFiles[i], topLevelOrRecursive, newReferencedFiles); } catch (Exception e) { didErrorOccur = true; errorMessage += e.Message; } } else { didErrorOccur = true; errorMessage += "Could not find the file " + newReferencedFiles[i] + " which is referenced in the file " + fileName + "\n"; } } } } // Files may include "../", so let's get rid of that stuff for (int i = 0; i < newReferencedFiles.Count; i++) { newReferencedFiles[i] = FileManager.Standardize(newReferencedFiles[i], "", false); } referencedFiles.AddRange(newReferencedFiles); if (didErrorOccur) { throw new Exception(errorMessage); } } }