예제 #1
0
        private void ExtractAllUncompressedButtonDATA_Click(object sender, RoutedEventArgs e)
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };

            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                foreach (DATA0Entry entry in data0)
                {
                    if (entry.CompressedSize == 0 || entry.UncompressedSize == 0)
                    {
                        continue;
                    }

                    using (EndianBinaryReader r = new EndianBinaryReader(new FileStream(data1Filepath, FileMode.Open), Endianness.Little))
                    {
                        using (EndianBinaryWriter w = new EndianBinaryWriter(new FileStream(dialog.FileName + "/" + entry.EntryID + ".bin", FileMode.Create), Endianness.Little))
                        {
                            if (entry.Compressed)
                            {
                                KTGZip zlib = new KTGZip();
                                r.SeekBegin(entry.Offset);
                                w.Write(zlib.Decompress(r.ReadBytes((int)entry.CompressedSize)));
                            }
                            else
                            {
                                r.SeekBegin(entry.Offset);
                                w.Write(r.ReadBytes(( int )entry.UncompressedSize));
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        private void ExtractDecompress_Click(object sender, RoutedEventArgs e)
        {
            DATA0Entry entry = (DATA0Entry)dataGridDATA.SelectedItem;

            SaveFileDialog dialog = new SaveFileDialog {
                DefaultExt = ".bin", FileName = entry.EntryID.ToString(), Filter = "FETH DATA0 Entry|*.bin"
            };

            if (entry.Compressed)
            {
                if (dialog.ShowDialog() == true)
                {
                    using (EndianBinaryReader r = new EndianBinaryReader(new FileStream(data1Filepath, FileMode.Open), Endianness.Little))
                    {
                        using (EndianBinaryWriter w = new EndianBinaryWriter(new FileStream(dialog.FileName, FileMode.Create), Endianness.Little))
                        {
                            KTGZip zlib = new KTGZip();
                            r.SeekBegin(entry.Offset);
                            w.Write(zlib.Decompress(r.ReadBytes((int)entry.CompressedSize)));
                        }
                    }
                }
            }
        }