Esempio n. 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)
                {
                    ZLib.DecompressData(e.RawData, out byte[] od);
                    e.RawData = od;
                    fs.Close();
                    e.Size       = od.Length;
                    e.Compressed = false;
                }

                r        = null;
                fs       = null;
                e.Loaded = true;
            }
            return(e);
        }
Esempio n. 2
0
 public void Save(string name, bool compressed)
 {
     if (compressed)
     {
         foreach (VirtualEntry v in Enteries)
         {
             if (v.Compressed == false)
             {
                 int ol = v.RawData.Length;
                 ZLib.CompressData(v.RawData, out byte[] 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);
 }
Esempio n. 3
0
        public void ScanFolder(string path)
        {
            FileInfo[]      fl = new DirectoryInfo(path).GetFiles();
            DirectoryInfo[] dl = new DirectoryInfo(path).GetDirectories();
            foreach (FileInfo file in fl)
            {
                FileInfo     fi = new FileInfo(file.FullName);
                VirtualEntry fe = Find(fi.Name, path);
                if (fe != null)
                {
                    if (fe.Size != fi.Length)
                    {
                    }
                }
                else
                {
                    VirtualFile entry = new VirtualFile
                    {
                        Name    = fi.Name,
                        Path    = path,
                        Size    = fi.Length,
                        RawData = File.ReadAllBytes(fi.FullName)
                    };
                    int os = entry.RawData.Length;
                    ZLib.CompressData(entry.RawData, out byte[] od);
                    entry.RawData = od;

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