quazipfileinfo.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #ifndef QUA_ZIPFILEINFO_H
  2. #define QUA_ZIPFILEINFO_H
  3. /*
  4. Copyright (C) 2005-2014 Sergey A. Tachenov
  5. This file is part of QuaZIP.
  6. QuaZIP is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Lesser General Public License as published by
  8. the Free Software Foundation, either version 2.1 of the License, or
  9. (at your option) any later version.
  10. QuaZIP is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
  16. See COPYING file for the full LGPL text.
  17. Original ZIP package is copyrighted by Gilles Vollant and contributors,
  18. see quazip/(un)zip.h files for details. Basically it's the zlib license.
  19. */
  20. #include <QByteArray>
  21. #include <QDateTime>
  22. #include <QFile>
  23. #include "quazip_global.h"
  24. /// Information about a file inside archive.
  25. /**
  26. * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files,
  27. * but also more convenience methods as well.
  28. *
  29. * Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to
  30. * fill this structure. */
  31. struct QUAZIP_EXPORT QuaZipFileInfo {
  32. /// File name.
  33. QString name;
  34. /// Version created by.
  35. quint16 versionCreated;
  36. /// Version needed to extract.
  37. quint16 versionNeeded;
  38. /// General purpose flags.
  39. quint16 flags;
  40. /// Compression method.
  41. quint16 method;
  42. /// Last modification date and time.
  43. QDateTime dateTime;
  44. /// CRC.
  45. quint32 crc;
  46. /// Compressed file size.
  47. quint32 compressedSize;
  48. /// Uncompressed file size.
  49. quint32 uncompressedSize;
  50. /// Disk number start.
  51. quint16 diskNumberStart;
  52. /// Internal file attributes.
  53. quint16 internalAttr;
  54. /// External file attributes.
  55. quint32 externalAttr;
  56. /// Comment.
  57. QString comment;
  58. /// Extra field.
  59. QByteArray extra;
  60. /// Get the file permissions.
  61. /**
  62. Returns the high 16 bits of external attributes converted to
  63. QFile::Permissions.
  64. */
  65. QFile::Permissions getPermissions() const;
  66. };
  67. /// Information about a file inside archive (with zip64 support).
  68. /** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to
  69. * fill this structure. */
  70. struct QUAZIP_EXPORT QuaZipFileInfo64 {
  71. /// File name.
  72. QString name;
  73. /// Version created by.
  74. quint16 versionCreated;
  75. /// Version needed to extract.
  76. quint16 versionNeeded;
  77. /// General purpose flags.
  78. quint16 flags;
  79. /// Compression method.
  80. quint16 method;
  81. /// Last modification date and time.
  82. /**
  83. * This is the time stored in the standard ZIP header. This format only allows
  84. * to store time with 2-second precision, so the seconds will always be even
  85. * and the milliseconds will always be zero. If you need more precise
  86. * date and time, you can try to call the getNTFSmTime() function or
  87. * its siblings, provided that the archive itself contains these NTFS times.
  88. */
  89. QDateTime dateTime;
  90. /// CRC.
  91. quint32 crc;
  92. /// Compressed file size.
  93. quint64 compressedSize;
  94. /// Uncompressed file size.
  95. quint64 uncompressedSize;
  96. /// Disk number start.
  97. quint16 diskNumberStart;
  98. /// Internal file attributes.
  99. quint16 internalAttr;
  100. /// External file attributes.
  101. quint32 externalAttr;
  102. /// Comment.
  103. QString comment;
  104. /// Extra field.
  105. QByteArray extra;
  106. /// Get the file permissions.
  107. /**
  108. Returns the high 16 bits of external attributes converted to
  109. QFile::Permissions.
  110. */
  111. QFile::Permissions getPermissions() const;
  112. /// Converts to QuaZipFileInfo
  113. /**
  114. If any of the fields are greater than 0xFFFFFFFFu, they are set to
  115. 0xFFFFFFFFu exactly, not just truncated. This function should be mainly used
  116. for compatibility with the old code expecting QuaZipFileInfo, in the cases
  117. when it's impossible or otherwise unadvisable (due to ABI compatibility
  118. reasons, for example) to modify that old code to use QuaZipFileInfo64.
  119. \return \c true if all fields converted correctly, \c false if an overflow
  120. occured.
  121. */
  122. bool toQuaZipFileInfo(QuaZipFileInfo &info) const;
  123. /// Returns the NTFS modification time
  124. /**
  125. * The getNTFS*Time() functions only work if there is an NTFS extra field
  126. * present. Otherwise, they all return invalid null timestamps.
  127. * @param fineTicks If not NULL, the fractional part of milliseconds returned
  128. * there, measured in 100-nanosecond ticks. Will be set to
  129. * zero if there is no NTFS extra field.
  130. * @sa dateTime
  131. * @sa getNTFSaTime()
  132. * @sa getNTFScTime()
  133. * @return The NTFS modification time, UTC
  134. */
  135. QDateTime getNTFSmTime(int *fineTicks = NULL) const;
  136. /// Returns the NTFS access time
  137. /**
  138. * The getNTFS*Time() functions only work if there is an NTFS extra field
  139. * present. Otherwise, they all return invalid null timestamps.
  140. * @param fineTicks If not NULL, the fractional part of milliseconds returned
  141. * there, measured in 100-nanosecond ticks. Will be set to
  142. * zero if there is no NTFS extra field.
  143. * @sa dateTime
  144. * @sa getNTFSmTime()
  145. * @sa getNTFScTime()
  146. * @return The NTFS access time, UTC
  147. */
  148. QDateTime getNTFSaTime(int *fineTicks = NULL) const;
  149. /// Returns the NTFS creation time
  150. /**
  151. * The getNTFS*Time() functions only work if there is an NTFS extra field
  152. * present. Otherwise, they all return invalid null timestamps.
  153. * @param fineTicks If not NULL, the fractional part of milliseconds returned
  154. * there, measured in 100-nanosecond ticks. Will be set to
  155. * zero if there is no NTFS extra field.
  156. * @sa dateTime
  157. * @sa getNTFSmTime()
  158. * @sa getNTFSaTime()
  159. * @return The NTFS creation time, UTC
  160. */
  161. QDateTime getNTFScTime(int *fineTicks = NULL) const;
  162. /// Checks whether the file is encrypted.
  163. bool isEncrypted() const {return (flags & 1) != 0;}
  164. };
  165. #endif