예제 #1
0
 public void extract(Label pb)
 {
     icp = new ICP();
     System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(exthread));
     t.Name = "DFC_Extracter";
     t.Start();
     while (!extracting)
     {
         System.Threading.Thread.Sleep(1);
         Application.DoEvents();
     }
     while (extracting)
     {
         double progress = icp.i * 1.0 / toExtract;
         pb.Width = (int)(progress * 600);
         Application.DoEvents();
         System.Threading.Thread.Sleep(10);
     }
 }
예제 #2
0
 public void make(Label pb)
 {
     icp = new ICP();
     new System.Threading.Thread(new System.Threading.ThreadStart(makeDFC)).Start();
     while (!encoding)
     {
         System.Threading.Thread.Sleep(1);
         Application.DoEvents();
     }
     while (encoding)
     {
         double progress = (icp.i + bytesCompressed) * 1.0 / bytesToCompress;
         //this.Text = string.Format("{0:0.00}%", Math.Round(progress * 100, 2)).Replace(".", " . ");
         pb.Width = (int)(progress * 600);
         Application.DoEvents();
         System.Threading.Thread.Sleep(10);
     }
     //this.Text = "done";
     MessageBox.Show("new dfc ok");
 }
예제 #3
0
        bool extract(Stream si, long end, string filename, ICP icp)
        {
            SevenZip.Compression.LZMA.Decoder dec = new SevenZip.Compression.LZMA.Decoder();
            //using (MemoryStream msi = new MemoryStream(GamePatcher.Properties.Resources.kengeki1))
            using (FileStream fso = new FileStream(filename, FileMode.Create))
            {
                byte[] props = new byte[5];
                si.Read(props, 0, 5);

                byte[] length = new byte[8];
                si.Read(length, 0, 8);

                long len = BitConverter.ToInt64(length, 0);

                dec.SetDecoderProperties(props);
                //dec.Code(si, fso, si.Length, len, null);
                dec.Code(si, fso, end, len, icp);
            }
            //si.Close();
            return(true);
        }
예제 #4
0
        void makeDFC()
        {
            archivequeue = new List <string>();
            string src = Path.GetFullPath(@"..\..\tools\");

            recurse(src, archivequeue);
            string[] files = archivequeue.ToArray();
            for (int a = 0; a < files.Length; a++)
            {
                files[a] = files[a].Substring(src.Length).Replace('\\', '/');
            }

            int filenameslength = 0;

            long[]   cLen     = new long[files.Length];
            long[]   eLen     = new long[files.Length];
            byte[][] filename = new byte[files.Length][];
            for (int a = 0; a < files.Length; a++)
            {
                eLen[a]          = new FileInfo(src + files[a]).Length;
                filename[a]      = Encoding.UTF8.GetBytes(files[a]);
                filenameslength += filename[a].Length;
                bytesToCompress += eLen[a];
            }

            byte[] buffer = new byte[8192];
            byte[] header = new byte[
                4 +                // header     length
                4 +                // file       count
                files.Length * 4 + // filename   length
                files.Length * 8 + // compressed length
                files.Length * 8 + // extracted  length
                filenameslength
                            ];
            for (int a = 0; a < header.Length; a++)
            {
                header[a] = 0xFF;
            }

            using (FileStream fso = new FileStream(@"..\..\tools.dfc", FileMode.Create))
            {
                encoding = true;
                fso.Write(header, 0, header.Length);
                for (int a = 0; a < files.Length; a++)
                {
                    using (FileStream fsi = new FileStream(src + files[a], FileMode.Open, FileAccess.Read))
                    {
                        long pre = fso.Position;
                        SevenZip.Compression.LZMA.Encoder enc = new SevenZip.Compression.LZMA.Encoder();
                        enc.WriteCoderProperties(fso);
                        fso.Write(BitConverter.GetBytes(fsi.Length), 0, 8);
                        enc.Code(fsi, fso, fsi.Length, -1, icp);
                        cLen[a]          = fso.Position - pre;
                        bytesCompressed += icp.i;
                        icp              = new ICP();
                    }
                }
                using (MemoryStream msh = new MemoryStream(header.Length))
                {
                    msh.Write(BitConverter.GetBytes((Int32)header.Length), 0, 4);
                    msh.Write(BitConverter.GetBytes((Int32)files.Length), 0, 4);
                    foreach (byte[] fn in filename)
                    {
                        msh.Write(BitConverter.GetBytes((Int32)fn.Length), 0, 4);
                    }
                    foreach (long cLn in cLen)
                    {
                        msh.Write(BitConverter.GetBytes((Int64)cLn), 0, 8);
                    }
                    foreach (long eLn in eLen)
                    {
                        msh.Write(BitConverter.GetBytes((Int64)eLn), 0, 8);
                    }
                    foreach (byte[] fn in filename)
                    {
                        msh.Write(fn, 0, fn.Length);
                    }
                    fso.Seek(0, SeekOrigin.Begin);
                    msh.Seek(0, SeekOrigin.Begin);
                    msh.WriteTo(fso);
                }
            }
            encoding = false;
        }
예제 #5
0
파일: DFC.cs 프로젝트: 9001/Loopstream
        void makeDFC()
        {
            archivequeue = new List<string>();
            string src = Path.GetFullPath(@"..\..\tools\");
            recurse(src, archivequeue);
            string[] files = archivequeue.ToArray();
            for (int a = 0; a < files.Length; a++)
            {
                files[a] = files[a].Substring(src.Length).Replace('\\', '/');
            }

            int filenameslength = 0;
            long[] cLen = new long[files.Length];
            long[] eLen = new long[files.Length];
            byte[][] filename = new byte[files.Length][];
            for (int a = 0; a < files.Length; a++)
            {
                eLen[a] = new FileInfo(src + files[a]).Length;
                filename[a] = Encoding.UTF8.GetBytes(files[a]);
                filenameslength += filename[a].Length;
                bytesToCompress += eLen[a];
            }

            byte[] buffer = new byte[8192];
            byte[] header = new byte[
                            4 + // header     length
                            4 + // file       count
               files.Length * 4 + // filename   length
               files.Length * 8 + // compressed length
               files.Length * 8 + // extracted  length
                filenameslength
            ];
            for (int a = 0; a < header.Length; a++)
            {
                header[a] = 0xFF;
            }

            using (FileStream fso = new FileStream(@"..\..\tools.dfc", FileMode.Create))
            {
                encoding = true;
                fso.Write(header, 0, header.Length);
                for (int a = 0; a < files.Length; a++)
                {
                    using (FileStream fsi = new FileStream(src + files[a], FileMode.Open, FileAccess.Read))
                    {
                        long pre = fso.Position;
                        SevenZip.Compression.LZMA.Encoder enc = new SevenZip.Compression.LZMA.Encoder();
                        enc.WriteCoderProperties(fso);
                        fso.Write(BitConverter.GetBytes(fsi.Length), 0, 8);
                        enc.Code(fsi, fso, fsi.Length, -1, icp);
                        cLen[a] = fso.Position - pre;
                        bytesCompressed += icp.i;
                        icp = new ICP();

                    }
                }
                using (MemoryStream msh = new MemoryStream(header.Length))
                {
                    msh.Write(BitConverter.GetBytes((Int32)header.Length), 0, 4);
                    msh.Write(BitConverter.GetBytes((Int32)files.Length), 0, 4);
                    foreach (byte[] fn in filename)
                    {
                        msh.Write(BitConverter.GetBytes((Int32)fn.Length), 0, 4);
                    }
                    foreach (long cLn in cLen)
                    {
                        msh.Write(BitConverter.GetBytes((Int64)cLn), 0, 8);
                    }
                    foreach (long eLn in eLen)
                    {
                        msh.Write(BitConverter.GetBytes((Int64)eLn), 0, 8);
                    }
                    foreach (byte[] fn in filename)
                    {
                        msh.Write(fn, 0, fn.Length);
                    }
                    fso.Seek(0, SeekOrigin.Begin);
                    msh.Seek(0, SeekOrigin.Begin);
                    msh.WriteTo(fso);
                }
            }
            encoding = false;
        }
예제 #6
0
파일: DFC.cs 프로젝트: 9001/Loopstream
        bool extract(Stream si, long end, string filename, ICP icp)
        {
            SevenZip.Compression.LZMA.Decoder dec = new SevenZip.Compression.LZMA.Decoder();
            //using (MemoryStream msi = new MemoryStream(GamePatcher.Properties.Resources.kengeki1))
            using (FileStream fso = new FileStream(filename, FileMode.Create))
            {
                byte[] props = new byte[5];
                si.Read(props, 0, 5);

                byte[] length = new byte[8];
                si.Read(length, 0, 8);

                long len = BitConverter.ToInt64(length, 0);

                dec.SetDecoderProperties(props);
                //dec.Code(si, fso, si.Length, len, null);
                dec.Code(si, fso, end, len, icp);
            }
            //si.Close();
            return true;
        }
예제 #7
0
파일: DFC.cs 프로젝트: 9001/Loopstream
 public void make(Label pb)
 {
     icp = new ICP();
     new System.Threading.Thread(new System.Threading.ThreadStart(makeDFC)).Start();
     while (!encoding)
     {
         System.Threading.Thread.Sleep(1);
         Application.DoEvents();
     }
     while (encoding)
     {
         double progress = (icp.i + bytesCompressed) * 1.0 / bytesToCompress;
         //this.Text = string.Format("{0:0.00}%", Math.Round(progress * 100, 2)).Replace(".", " . ");
         pb.Width = (int)(progress * 600);
         Application.DoEvents();
         System.Threading.Thread.Sleep(10);
     }
     //this.Text = "done";
     MessageBox.Show("new dfc ok");
 }
예제 #8
0
파일: DFC.cs 프로젝트: 9001/Loopstream
 public void extract(Label pb)
 {
     icp = new ICP();
     System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(exthread));
     t.Name = "DFC_Extracter";
     t.Start();
     while (!extracting)
     {
         System.Threading.Thread.Sleep(1);
         Application.DoEvents();
     }
     while (extracting)
     {
         double progress = icp.i * 1.0 / toExtract;
         pb.Width = (int)(progress * 600);
         Application.DoEvents();
         System.Threading.Thread.Sleep(10);
     }
 }