public CompressionInfo(Stream file, CryptoClass crypto) { byte[] headBytes = new byte[Header.HeadBegin.Length]; file.Position = 0; file.Read(headBytes, 0, headBytes.Length); if (crypto != null) { if (!headBytes.SequenceEqual(Header.HeadEncBegin)) { throw new NotAnOOFPackException(); } } else { if (headBytes.SequenceEqual(Header.HeadEncBegin)) { throw new EncryptedException(); } else if (!headBytes.SequenceEqual(Header.HeadBegin)) { throw new NotAnOOFPackException(); } } HeadBytes = ResolveHead(file, out int offset); Diff = ResolveDiff(HeadBytes); BufferSize = ResolveBufferSize(HeadBytes); Files = ResolveFiles(HeadBytes); DataPos = Header.HeadBegin.Length + sizeof(int) + offset; PacketAmount = Diff.Count; foreach (uint i in Diff) { TotalCompressRatio += ((BufferSize - i) / (BufferSize * (double)PacketAmount)); } foreach (FileData f in Files) { TotalUncompressedSize += f.Length; } }
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(); }
public FileBuilder(string[] inputFiles, uint BufferSize, CryptoClass crypto) { this.inputFiles = inputFiles; this.BufferSize = BufferSize; this.crypto = crypto; }
public FileBuilder(string[] inputFiles, CryptoClass crypto) : this(inputFiles, 1048576, crypto) { }
public DecompressionStream(Stream toDecompressStream, CompressionInfo compressionInfo, CryptoClass crypto) { this.crypto = crypto; inputStream = toDecompressStream; ci = compressionInfo; Position = 0; }
public DecompressionStream(Stream toDecompressStream, CryptoClass crypto) : this(toDecompressStream, null, crypto) { ci = new CompressionInfo(toDecompressStream, null); }
public FileUnpacker(string filePathtoUnpack, CryptoClass crypto) : this(filePathtoUnpack, crypto, CancellationToken.None) { }