Example #1
0
        public void extract(string extFolder, bool timeoutSkip = false)
        {
            int OFFSET   = 0;
            int INT_SIZE = (int)intf.Length;

            foreach (SectionInfo info in infos)
            {
                long DATA_OFF = info.dataOffset;
                BUFF_OFF = (int)DATA_OFF;
                long SIZE  = getLong(BUFF_OFF);
                long ZSIZE = getLong(BUFF_OFF);
                OFFSET = BUFF_OFF;

                /*hoo boy
                 * the clog
                 * cloggy boy
                 * hmmmmmmmmmmmmmmmm*/
                intf.Seek(DATA_OFF, SeekOrigin.Begin);

                /*byte[] MEMORY_FILE = new byte[ZSIZE];
                 * intf.Read(MEMORY_FILE, 0, (int)ZSIZE);
                 * //COPY THE ENTIRETY MY BOYO*/
                //byte[] MEMORY_FILE = inta; //please help
                byte[] MEMORY_FILE = new byte[ZSIZE];
                //byte[] TEMP_FILE = new byte[ZSIZE];
                //intf.Read(TEMP_FILE, 0, (int)ZSIZE);
                intf.Read(MEMORY_FILE, 0, (int)ZSIZE);
                //Stream TEMP_STREAM = new MemoryStream(TEMP_FILE);
                //TEMP_STREAM = Decompress(TEMP_STREAM);
                //TEMP_STREAM.Read(MEMORY_FILE, 0, (int)SIZE);
                foreach (INTFile file in info.files)
                {
                    OFFSET = (int)file.dataOffset;
                    SIZE   = file.size;
                    string NAME  = file.name;
                    string FNAME = string.Format(@"\{0}\{1}", info.folderName, NAME);
                    //the big EXPORT TIME
                    //Console.WriteLine(extFolder + FNAME);
                    if (!Directory.Exists(extFolder + @"\" + info.folderName))
                    {
                        Directory.CreateDirectory(extFolder + @"\" + info.folderName);
                    }
                    //Console.WriteLine(OFFSET + " " + SIZE);
                    Stream EXPORT;
                    try
                    {
                        EXPORT = File.Open(extFolder + FNAME, FileMode.CreateNew);
                    }
                    catch (IOException)
                    {
                        EXPORT = File.Open(extFolder + FNAME, FileMode.Truncate);
                    };
                    //Console.WriteLine(NAME);
                    byte[] WRITTEN_FILE = new byte[SIZE];
                    EXPORT.Read(WRITTEN_FILE, (int)OFFSET, (int)SIZE);
                    FileInfo fl  = new FileInfo(extFolder + FNAME);
                    int      r   = 0;
                    bool     c   = false;
                    long     osz = 0;
                    if (timeoutSkip)
                    {
                        while (fl.Length != SIZE)
                        {
                            fl.Refresh();
                            r++;
                            if (fl.Length != osz)
                            {
                                r = 0;
                            }

                            if (r > 100000)
                            {
                                //Console.WriteLine(SIZE + " " + OFFSET);
                                c = true;
                                break; //move on, continue to attempt to write in bg
                            }
                        }
                    }
                    if (!c)
                    {
                        EXPORT.Close();
                    }
                }
            }
            ////Console.WriteLine(getLong(skipZeroes()));
        }