public static RFile findFile(string name, RFile.RFileType type) { //return Files.Where(f => f.FullName == name).FirstOrDefault(); foreach (var item in Files) { if (item.FullName == name && item.Type == type) return item; } return new RFile(); }
public static void LoadResources() { Misc.CheckArchive(ArchivePath); using (ZipArchive archive = ZipFile.Open(ArchivePath, ZipArchiveMode.Read, Global.Encoding)) { Files.Clear(); foreach (var e in archive.Entries) { if (e.Name == "") continue; RFile f = new RFile(e.FullName); f.Size = e.Length; if (f.Type == RFile.RFileType.Texture) f.Id = LoadImage(e); else if (f.Type == RFile.RFileType.Mesh) f.obj = LoadMesh(e, f.Folder); Files.Add(f); } } }
public static void AddFile(string path, string toFolder) { using (ZipArchive archive = ZipFile.Open(ArchivePath, ZipArchiveMode.Update, Global.Encoding)) { ZipArchiveEntry e = archive.CreateEntry(toFolder+Misc.pathName(path)); Stream s = e.Open(); File.OpenRead(path).CopyTo(s); RFile f = new RFile(e.FullName); f.Size = s.Length; s.Close(); if (f.Type == RFile.RFileType.Texture) f.Id = LoadImage(e); else if (f.Type == RFile.RFileType.Mesh) f.obj = LoadMesh(e, f.Folder); f.Folder = toFolder; Files.Add(f); } }