コード例 #1
0
ファイル: FileUnpacker.cs プロジェクト: Snaggly/OOF-Archive
            public override int Read(byte[] buffer, int offset, int count)
            {
                int i;

                for (i = 0; i < count && Position < Length; i++)
                {
                    buffer[i + offset] = (byte)inStream.ReadByte();
                }
                return(i);
            }
コード例 #2
0
ファイル: FileUnpacker.cs プロジェクト: Snaggly/OOF-Archive
        public FileUnpacker(string filePathtoUnpack, CryptoClass crypto, CancellationToken ct)
        {
            Token        = ct;
            filePath     = filePathtoUnpack;
            this.crypto  = crypto;
            inputStream  = new FileStream(filePathtoUnpack, FileMode.Open, FileAccess.Read);
            compressInfo = new CompressionInfo(inputStream, crypto);
            try
            {
                decompStream = new DecompressionStream(inputStream, compressInfo, crypto);
                decompStream.ReadByte();
                decompStream.Dispose();
            }
            catch (System.Security.Cryptography.CryptographicException)
            {
                inputStream.Dispose();
                throw new IncorrectKeyException();
            }

            fileDatas = compressInfo.Files;

            inputStream.Dispose();
        }