예제 #1
0
 public override void Write(Stream stream)
 {
     // optimization: Check if we have the data from the original file, and we don't need to encrypt and compress it again
     if (this.Compressed && this.Data.GetType() == typeof(CompressedFileStreamCreator))
     {
         (this.Data as CompressedFileStreamCreator).WriteRaw(stream);
     }
     else if (!this.Compressed && this.Data.GetType() == typeof(FileStreamCreator))
     {
         (this.Data as FileStreamCreator).WriteRaw(stream);
     }
     else
     {
         // we need to create it..
         Stream baseStream = new StreamKeeper(stream);
         using (Stream input = this.Data.GetStream())
         {
             using (Stream output = this.Compressed ? Platform.GetCompressStream(AES.EncryptStream(baseStream)) : baseStream)
             {
                 input.CopyTo(output);
             }
         }
     }
 }
예제 #2
0
 public override void Write(Stream stream)
 {
     // 0x10 ignored bytes
     stream.Write(new byte[0x10], 0, 0x10);
     // optimization: Check if we have the data from the original file, and we don't need to encrypt and compress it again
     if (this.Data.GetType() == typeof(CompressedFileStreamCreator) && (this.Data as CompressedFileStreamCreator).Encrypted == IsResourceEncrypted(this.Type))
     {
         (this.Data as CompressedFileStreamCreator).WriteRaw(stream);
     }
     else
     {
         // we need to create it..
         Stream baseStream = new StreamKeeper(stream);
         using (Stream input = this.Data.GetStream())
         {
             using (Stream output = IsResourceEncrypted(this.Type) ? Platform.GetCompressStream(AES.EncryptStream(baseStream)) : Platform.GetCompressStream(baseStream))
             {
                 input.CopyTo(output);
             }
         }
     }
 }