예제 #1
0
        public VirtualEntry Load(VirtualEntry e)
        {
            //name = name.ToLower();
            //path = path.ToLower();


            if (e.Loaded == false)
            {
                FileStream   fs = new FileStream(arcpath, FileMode.Open, FileAccess.Read);
                BinaryReader r  = new BinaryReader(fs);
                e.RawData = new byte[(int)e.Size];
                fs.Seek(e.Start, SeekOrigin.Begin);
                r.Read(e.RawData, 0, (int)e.Size);
                if (e.Compressed)
                {
                    byte[] od;
                    ZLib.DecompressData(e.RawData, out od);
                    e.RawData = od;
                    fs.Close();
                    e.Size       = od.Length;
                    e.Compressed = false;
                }

                r        = null;
                fs       = null;
                e.Loaded = true;
            }
            return(e);
        }
예제 #2
0
 public void Save(string name, bool compressed)
 {
     if (compressed)
     {
         foreach (var v in Enteries)
         {
             if (v.Compressed == false)
             {
                 byte[] od = null;
                 ZLib.CompressData(v.RawData, out od);
                 v.RawData    = od;
                 v.Size       = od.Length;
                 v.Compressed = true;
             }
         }
     }
     SaveTOC(name);
     SaveFS(name);
 }
예제 #3
0
 public void Save(string name, bool compressed)
 {
     if (compressed)
     {
         foreach (var v in Enteries)
         {
             if (v.Compressed == false)
             {
                 int    ol = v.RawData.Length;
                 byte[] od = null;
                 ZLib.CompressData(v.RawData, out od);
                 v.RawData    = od;
                 v.Size       = od.Length;
                 v.Compressed = true;
                 int nl = v.RawData.Length;
                 Console.WriteLine("E:" + v.Name + " Old:" + ol + " New:" + nl);
             }
         }
     }
     SaveTOC(name);
     SaveFS(name);
 }
예제 #4
0
        public void ScanFolder(string path)
        {
            var fl = new DirectoryInfo(path).GetFiles();
            var dl = new DirectoryInfo(path).GetDirectories();

            foreach (var file in fl)
            {
                var fi = new FileInfo(file.FullName);
                var fe = Find(fi.Name, path);
                if (fe != null)
                {
                    if (fe.Size != fi.Length)
                    {
                    }
                }
                else
                {
                    var entry = new VirtualFile();
                    entry.Name    = fi.Name;
                    entry.Path    = path;
                    entry.Size    = fi.Length;
                    entry.RawData = File.ReadAllBytes(fi.FullName);
                    byte[] od = null;
                    int    os = entry.RawData.Length;
                    ZLib.CompressData(entry.RawData, out od);
                    entry.RawData = od;

                    entry.Size = entry.RawData.Length;
                    Console.WriteLine("Adding:" + entry.Name);
                    Enteries.Add(entry);
                }
            }
            foreach (var dir in dl)
            {
                ScanFolder(dir.FullName);
            }
        }