コード例 #1
0
ファイル: FileIO.cs プロジェクト: PokeD/Ohana3DS-Rebirth
        /// <summary>
        ///     Decompress a file and automaticaly updates the format of the compressed file.
        /// </summary>
        /// <param name="data">Stream with the file to be decompressed</param>
        /// <param name="format">Format of the compression</param>
        /// <returns></returns>
        public static void decompress(ref Stream data, ref fileFormat format)
        {
            BinaryReader input = new BinaryReader(data);
            byte[] decompressedData, content;
            uint length;

            switch (format)
            {
                case fileFormat.cmpBLZ:
                    decompressedData = BLZ.decompress(data);
                    content = new byte[decompressedData.Length - 1];
                    Buffer.BlockCopy(decompressedData, 1, content, 0, content.Length);
                    data = new MemoryStream(content);
                    format = identify(data);
                    break;
                case fileFormat.cmpIECP: //Stella Glow
                    uint magic = input.ReadUInt32();
                    length = input.ReadUInt32();
                    decompressedData = LZSS.decompress(data, length);
                    data = new MemoryStream(decompressedData);
                    format = identify(data);
                    break;
                case fileFormat.cmpLZSS:
                case fileFormat.cmpLZSSHeader:
                    if (format == fileFormat.cmpLZSSHeader) input.ReadUInt32();
                    length = input.ReadUInt32() >> 8;
                    decompressedData = LZSS_Ninty.decompress(data, length);
                    data = new MemoryStream(decompressedData);
                    format = identify(data);
                    break;
            }
        }
コード例 #2
0
ファイル: FileIO.cs プロジェクト: PokeD/Ohana3DS-Rebirth
        /// <summary>
        ///     Returns true if the format is a compression format, and false otherwise.
        /// </summary>
        /// <param name="format">The format of the file</param>
        /// <returns></returns>
        public static bool isCompressed(fileFormat format)
        {
            switch (format)
            {
                case fileFormat.cmpBLZ:
                case fileFormat.cmpIECP:
                case fileFormat.cmpLZSS:
                case fileFormat.cmpLZSSHeader:
                    return true;
            }

            return false;
        }