RarEntry.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using SharpCompress.Common.Rar.Headers;
  3. namespace SharpCompress.Common.Rar
  4. {
  5. public abstract class RarEntry : Entry
  6. {
  7. internal abstract FileHeader FileHeader { get; }
  8. /// <summary>
  9. /// As the V2017 port isn't complete, add this check to use the legacy Rar code.
  10. /// </summary>
  11. internal bool IsRarV3 => FileHeader.CompressionAlgorithm == 29 || FileHeader.CompressionAlgorithm == 36;
  12. /// <summary>
  13. /// The File's 32 bit CRC Hash
  14. /// </summary>
  15. public override long Crc => FileHeader.FileCrc;
  16. /// <summary>
  17. /// The path of the file internal to the Rar Archive.
  18. /// </summary>
  19. public override string Key => FileHeader.FileName;
  20. /// <summary>
  21. /// The entry last modified time in the archive, if recorded
  22. /// </summary>
  23. public override DateTime? LastModifiedTime => FileHeader.FileLastModifiedTime;
  24. /// <summary>
  25. /// The entry create time in the archive, if recorded
  26. /// </summary>
  27. public override DateTime? CreatedTime => FileHeader.FileCreatedTime;
  28. /// <summary>
  29. /// The entry last accessed time in the archive, if recorded
  30. /// </summary>
  31. public override DateTime? LastAccessedTime => FileHeader.FileLastAccessedTime;
  32. /// <summary>
  33. /// The entry time whend archived, if recorded
  34. /// </summary>
  35. public override DateTime? ArchivedTime => FileHeader.FileArchivedTime;
  36. /// <summary>
  37. /// Entry is password protected and encrypted and cannot be extracted.
  38. /// </summary>
  39. public override bool IsEncrypted => FileHeader.IsEncrypted;
  40. /// <summary>
  41. /// Entry is password protected and encrypted and cannot be extracted.
  42. /// </summary>
  43. public override bool IsDirectory => FileHeader.IsDirectory;
  44. public override bool IsSplitAfter => FileHeader.IsSplitAfter;
  45. public override string ToString()
  46. {
  47. return string.Format("Entry Path: {0} Compressed Size: {1} Uncompressed Size: {2} CRC: {3}",
  48. Key, CompressedSize, Size, Crc);
  49. }
  50. }
  51. }