示例#1
0
 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();
 }
示例#2
0
        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);
                }
            }
        }
示例#3
0
        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);
            }
        }