ArchiveFileInfo.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #if UNMANAGED
  2. namespace SevenZip
  3. {
  4. using System;
  5. using System.Globalization;
  6. /// <summary>
  7. /// Struct for storing information about files in the 7-zip archive.
  8. /// </summary>
  9. public struct ArchiveFileInfo
  10. {
  11. /// <summary>
  12. /// Gets or sets index of the file in the archive file table.
  13. /// </summary>
  14. [CLSCompliant(false)]
  15. public int Index { get; set; }
  16. /// <summary>
  17. /// Gets or sets file name
  18. /// </summary>
  19. public string FileName { get; set; }
  20. /// <summary>
  21. /// Gets or sets the file last write time.
  22. /// </summary>
  23. public DateTime LastWriteTime { get; set; }
  24. /// <summary>
  25. /// Gets or sets the file creation time.
  26. /// </summary>
  27. public DateTime CreationTime { get; set; }
  28. /// <summary>
  29. /// Gets or sets the file creation time.
  30. /// </summary>
  31. public DateTime LastAccessTime { get; set; }
  32. /// <summary>
  33. /// Gets or sets size of the file (unpacked).
  34. /// </summary>
  35. [CLSCompliant(false)]
  36. public ulong Size { get; set; }
  37. /// <summary>
  38. /// Gets or sets CRC checksum of the file.
  39. /// </summary>
  40. [CLSCompliant(false)]
  41. public uint Crc { get; set; }
  42. /// <summary>
  43. /// Gets or sets file attributes.
  44. /// </summary>
  45. [CLSCompliant(false)]
  46. public uint Attributes { get; set; }
  47. /// <summary>
  48. /// Gets or sets being a directory.
  49. /// </summary>
  50. public bool IsDirectory { get; set; }
  51. /// <summary>
  52. /// Gets or sets being encrypted.
  53. /// </summary>
  54. public bool Encrypted { get; set; }
  55. /// <summary>
  56. /// Gets or sets comment for the file.
  57. /// </summary>
  58. public string Comment { get; set; }
  59. /// <summary>
  60. /// Compression method for the file.
  61. /// </summary>
  62. public string Method { get; set; }
  63. /// <summary>
  64. /// Determines whether the specified System.Object is equal to the current ArchiveFileInfo.
  65. /// </summary>
  66. /// <param name="obj">The System.Object to compare with the current ArchiveFileInfo.</param>
  67. /// <returns>true if the specified System.Object is equal to the current ArchiveFileInfo; otherwise, false.</returns>
  68. public override bool Equals(object obj)
  69. {
  70. return obj is ArchiveFileInfo info && Equals(info);
  71. }
  72. /// <summary>
  73. /// Determines whether the specified ArchiveFileInfo is equal to the current ArchiveFileInfo.
  74. /// </summary>
  75. /// <param name="afi">The ArchiveFileInfo to compare with the current ArchiveFileInfo.</param>
  76. /// <returns>true if the specified ArchiveFileInfo is equal to the current ArchiveFileInfo; otherwise, false.</returns>
  77. public bool Equals(ArchiveFileInfo afi)
  78. {
  79. return afi.Index == Index && afi.FileName == FileName;
  80. }
  81. /// <summary>
  82. /// Serves as a hash function for a particular type.
  83. /// </summary>
  84. /// <returns> A hash code for the current ArchiveFileInfo.</returns>
  85. public override int GetHashCode()
  86. {
  87. return FileName.GetHashCode() ^ Index;
  88. }
  89. /// <summary>
  90. /// Returns a System.String that represents the current ArchiveFileInfo.
  91. /// </summary>
  92. /// <returns>A System.String that represents the current ArchiveFileInfo.</returns>
  93. public override string ToString()
  94. {
  95. return "[" + Index.ToString(CultureInfo.CurrentCulture) + "] " + FileName;
  96. }
  97. /// <summary>
  98. /// Determines whether the specified ArchiveFileInfo instances are considered equal.
  99. /// </summary>
  100. /// <param name="afi1">The first ArchiveFileInfo to compare.</param>
  101. /// <param name="afi2">The second ArchiveFileInfo to compare.</param>
  102. /// <returns>true if the specified ArchiveFileInfo instances are considered equal; otherwise, false.</returns>
  103. public static bool operator ==(ArchiveFileInfo afi1, ArchiveFileInfo afi2)
  104. {
  105. return afi1.Equals(afi2);
  106. }
  107. /// <summary>
  108. /// Determines whether the specified ArchiveFileInfo instances are not considered equal.
  109. /// </summary>
  110. /// <param name="afi1">The first ArchiveFileInfo to compare.</param>
  111. /// <param name="afi2">The second ArchiveFileInfo to compare.</param>
  112. /// <returns>true if the specified ArchiveFileInfo instances are not considered equal; otherwise, false.</returns>
  113. public static bool operator !=(ArchiveFileInfo afi1, ArchiveFileInfo afi2)
  114. {
  115. return !afi1.Equals(afi2);
  116. }
  117. }
  118. }
  119. #endif