コード例 #1
0
ファイル: MainForm.cs プロジェクト: neoxephon/darthnemesis
        private void DecompressFile(string fileName)
        {
            try
            {
                byte[] compressedData = StreamHelper.ReadFile(fileName);
                byte[] decompressedData;
                if (compressedData.Length > 0)
                {
                    this.type11ToolStripMenuItem.Checked = compressedData[0] == 0x11;
                    this.type10ToolStripMenuItem.Checked = !this.type11ToolStripMenuItem.Checked;
                }

                if (this.type11ToolStripMenuItem.Checked)
                {
                    decompressedData = CompressionManager.DecompressOnz(compressedData);
                }
                else
                {
                    decompressedData = CompressionManager.Decompress(compressedData);
                }

                if (decompressedData == null)
                {
                    throw new FormatException("Not a compressed file!");
                }

                string outFileName = fileName;
                if (!this.overwriteToolStripMenuItem.Checked)
                {
                    outFileName += ".decompressed";
                }

                StreamHelper.WriteFile(outFileName, decompressedData);
            }
            catch (SystemException exc)
            {
                this.errors.Add(string.Format(CultureInfo.CurrentCulture, "[{0}]: {1}", fileName, exc.Message));
            }
        }