コード例 #1
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);
 }
コード例 #2
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);
            }
        }