public static void Crawl(ContentModMetadata meta) { if (meta.Directory != null) { Crawl(meta, meta.Directory); } else if (meta.Archive != null) { using (ZipFile zip = ZipFile.Read(meta.Archive)) Crawl(meta, meta.Archive, zip); } else if (meta.Assembly != null) { Crawl(meta, meta.Assembly); } }
public static void Crawl(ContentModMetadata meta, string archive, ZipFile zip) { if (meta == null) { Mods.Add(meta = new ContentModMetadata() { Archive = archive }); } foreach (ZipEntry entry in zip.Entries) { string entryName = entry.FileName.Replace("\\", "/"); AddMapping(entryName, new AssetMetadata(archive, entryName) { AssetType = entry.IsDirectory ? typeof(AssetTypeDirectory) : null }); } }
public static void Crawl(ContentModMetadata meta, Assembly asm) { if (meta == null) { Mods.Add(meta = new ContentModMetadata() { Assembly = asm }); } string[] resourceNames = asm.GetManifestResourceNames(); for (int i = 0; i < resourceNames.Length; i++) { string name = resourceNames[i]; int indexOfContent = name.IndexOf("Content"); if (indexOfContent < 0) { continue; } name = name.Substring(indexOfContent + 8); AddMapping(name, new AssetMetadata(asm, resourceNames[i])); } }
public static void Crawl(ContentModMetadata meta, string dir, string root = null) { if (meta == null) { Mods.Add(meta = new ContentModMetadata() { Directory = dir }); } if (Path.GetFileName(dir).StartsWith("DUMP")) { return; } if (root == null) { root = dir; } string[] files = Directory.GetFiles(dir); for (int i = 0; i < files.Length; i++) { string file = files[i]; AddMapping(file.Substring((root?.Length ?? 0) + 1), new AssetMetadata(file)); } files = Directory.GetDirectories(dir); for (int i = 0; i < files.Length; i++) { string file = files[i]; AddMapping(file.Substring((root?.Length ?? 0) + 1), new AssetMetadata(file) { AssetType = Types.AssetTypeDirectory, HasData = false }); Crawl(meta, file, root); } }