public IFileProcessor CreateFileProcessor(FileInfo file, Proxy.IMapManager mapManager, Proxy.INode map, Point location) { if (file.Name.EndsWith(".zip")) { using (FileStream fileStream = file.OpenRead()) { bool isCompendiumExport = false; bool hasExportsFolderAndXml = false; bool hasLinkedFilesFolder = false; ZipFile zipFile = new ZipFile(fileStream); foreach (string filename in zipFile.FileNamesInZip) { if (filename.StartsWith("Exports/")) { if (filename.EndsWith(".xml")) { isCompendiumExport = true; //hasExportsFolderAndXml = true; break; } } //if (filename.StartsWith("Linked Files/")) //{ // hasLinkedFilesFolder = true; //} //if (hasExportsFolderAndXml && hasLinkedFilesFolder) //{ // isCompendiumExport = true; // break; //} } if (isCompendiumExport) { var compendiumFileProcessor = new CompendiumArchiveProcessor(file, mapManager, map); return compendiumFileProcessor; } } } else if (file.Name.EndsWith(".xml")) { using (var stream = file.OpenRead()) { var compendiumXmlProcessor = new CompendiumXmlFileProcessor(stream, "", ""); compendiumXmlProcessor.MapManager = mapManager; compendiumXmlProcessor.Map = map; if (compendiumXmlProcessor.Nodes.Any()) { return compendiumXmlProcessor; } } } return new DroppedFileProcessor(file, location); }
public IFileProcessor CreateFileProcessor(FileInfo file, Proxy.IMapManager mapManager, Proxy.INode map, Point location) { if (file.Name.EndsWith(".zip")) { using (FileStream fileStream = file.OpenRead()) { bool isCompendiumExport = false; bool hasExportsFolderAndXml = false; bool hasLinkedFilesFolder = false; ZipFile zipFile = new ZipFile(fileStream); foreach (string filename in zipFile.FileNamesInZip) { if (filename.StartsWith("Exports/")) { if (filename.EndsWith(".xml")) { isCompendiumExport = true; //hasExportsFolderAndXml = true; break; } } //if (filename.StartsWith("Linked Files/")) //{ // hasLinkedFilesFolder = true; //} //if (hasExportsFolderAndXml && hasLinkedFilesFolder) //{ // isCompendiumExport = true; // break; //} } if (isCompendiumExport) { var compendiumFileProcessor = new CompendiumArchiveProcessor(file, mapManager, map); return(compendiumFileProcessor); } } } else if (file.Name.EndsWith(".xml")) { using (var stream = file.OpenRead()) { var compendiumXmlProcessor = new CompendiumXmlFileProcessor(stream, "", ""); compendiumXmlProcessor.MapManager = mapManager; compendiumXmlProcessor.Map = map; if (compendiumXmlProcessor.Nodes.Any()) { return(compendiumXmlProcessor); } } } return(new DroppedFileProcessor(file, location)); }