From f9cc80e1dec3b8dd62a0497e62895726f85a4106 Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Fri, 29 Jun 2018 15:51:40 +0200 Subject: [PATCH] Correctly set IsEncrypted for entries in Rar5. --- .../Common/Rar/Headers/FileHeader.cs | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/SharpCompress/Common/Rar/Headers/FileHeader.cs b/src/SharpCompress/Common/Rar/Headers/FileHeader.cs index 829083e90..09ded0fc6 100644 --- a/src/SharpCompress/Common/Rar/Headers/FileHeader.cs +++ b/src/SharpCompress/Common/Rar/Headers/FileHeader.cs @@ -104,24 +104,27 @@ private void ReadFromReaderV5(MarkingBinaryReader reader) throw new InvalidFormatException("rar5 header size / extra size inconsistency"); } + isEncryptedRar5 = false; + while (RemainingHeaderBytes(reader) > 0) { var size = reader.ReadRarVIntUInt16(); int n = RemainingHeaderBytes(reader); var type = reader.ReadRarVIntUInt16(); switch (type) { -//TODO -// case 1: // file encryption -// { -// var version = reader.ReadRarVIntByte(); -// if (version != 0) throw new InvalidFormatException("unknown encryption algorithm "+ version); -// -// } -// break; -// case 2: // file hash -// { -// -// } -// break; + //TODO + case 1: // file encryption + { + isEncryptedRar5 = true; + + //var version = reader.ReadRarVIntByte(); + //if (version != 0) throw new InvalidFormatException("unknown encryption algorithm " + version); + } + break; + // case 2: // file hash + // { + // + // } + // break; case 3: // file time { ushort flags = reader.ReadRarVIntUInt16(); @@ -435,8 +438,8 @@ internal uint FileCrc public bool IsDirectory => HasFlag(IsRar5 ? FileFlagsV5.DIRECTORY : FileFlagsV4.DIRECTORY); -//!!! TODO rar5 - public bool IsEncrypted => HasFlag(FileFlagsV4.PASSWORD); + private bool isEncryptedRar5 = false; + public bool IsEncrypted => IsRar5 ? isEncryptedRar5: HasFlag(FileFlagsV4.PASSWORD); internal DateTime? FileLastModifiedTime { get; private set; }