1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/7zip/Archive/7z/7zItem.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,181 @@ 1.4 +// 7zItem.h 1.5 + 1.6 +#ifndef __7Z_ITEM_H 1.7 +#define __7Z_ITEM_H 1.8 + 1.9 +#include "../../../Common/Buffer.h" 1.10 +#include "7zMethodID.h" 1.11 +#include "7zHeader.h" 1.12 + 1.13 +namespace NArchive { 1.14 +namespace N7z { 1.15 + 1.16 +struct CAltCoderInfo 1.17 +{ 1.18 + CMethodID MethodID; 1.19 + CByteBuffer Properties; 1.20 +}; 1.21 + 1.22 +typedef UInt32 CNum; 1.23 +const CNum kNumMax = 0x7FFFFFFF; 1.24 +const CNum kNumNoIndex = 0xFFFFFFFF; 1.25 + 1.26 +struct CCoderInfo 1.27 +{ 1.28 + CNum NumInStreams; 1.29 + CNum NumOutStreams; 1.30 + CObjectVector<CAltCoderInfo> AltCoders; 1.31 + bool IsSimpleCoder() const { return (NumInStreams == 1) && (NumOutStreams == 1); } 1.32 +}; 1.33 + 1.34 +struct CBindPair 1.35 +{ 1.36 + CNum InIndex; 1.37 + CNum OutIndex; 1.38 +}; 1.39 + 1.40 +struct CFolder 1.41 +{ 1.42 + CObjectVector<CCoderInfo> Coders; 1.43 + CRecordVector<CBindPair> BindPairs; 1.44 + CRecordVector<CNum> PackStreams; 1.45 + CRecordVector<UInt64> UnPackSizes; 1.46 + UInt32 UnPackCRC; 1.47 + bool UnPackCRCDefined; 1.48 + 1.49 + CFolder(): UnPackCRCDefined(false) {} 1.50 + 1.51 + UInt64 GetUnPackSize() const // test it 1.52 + { 1.53 + if (UnPackSizes.IsEmpty()) 1.54 + return 0; 1.55 + for (int i = UnPackSizes.Size() - 1; i >= 0; i--) 1.56 + if (FindBindPairForOutStream(i) < 0) 1.57 + return UnPackSizes[i]; 1.58 + throw 1; 1.59 + } 1.60 + 1.61 + CNum GetNumOutStreams() const 1.62 + { 1.63 + CNum result = 0; 1.64 + for (int i = 0; i < Coders.Size(); i++) 1.65 + result += Coders[i].NumOutStreams; 1.66 + return result; 1.67 + } 1.68 + 1.69 + int FindBindPairForInStream(CNum inStreamIndex) const 1.70 + { 1.71 + for(int i = 0; i < BindPairs.Size(); i++) 1.72 + if (BindPairs[i].InIndex == inStreamIndex) 1.73 + return i; 1.74 + return -1; 1.75 + } 1.76 + int FindBindPairForOutStream(CNum outStreamIndex) const 1.77 + { 1.78 + for(int i = 0; i < BindPairs.Size(); i++) 1.79 + if (BindPairs[i].OutIndex == outStreamIndex) 1.80 + return i; 1.81 + return -1; 1.82 + } 1.83 + int FindPackStreamArrayIndex(CNum inStreamIndex) const 1.84 + { 1.85 + for(int i = 0; i < PackStreams.Size(); i++) 1.86 + if (PackStreams[i] == inStreamIndex) 1.87 + return i; 1.88 + return -1; 1.89 + } 1.90 +}; 1.91 + 1.92 +typedef FILETIME CArchiveFileTime; 1.93 + 1.94 +class CFileItem 1.95 +{ 1.96 +public: 1.97 + CArchiveFileTime CreationTime; 1.98 + CArchiveFileTime LastWriteTime; 1.99 + CArchiveFileTime LastAccessTime; 1.100 + UInt64 UnPackSize; 1.101 + UInt64 StartPos; 1.102 + UInt32 Attributes; 1.103 + UInt32 FileCRC; 1.104 + UString Name; 1.105 + 1.106 + bool HasStream; // Test it !!! it means that there is 1.107 + // stream in some folder. It can be empty stream 1.108 + bool IsDirectory; 1.109 + bool IsAnti; 1.110 + bool IsFileCRCDefined; 1.111 + bool AreAttributesDefined; 1.112 + bool IsCreationTimeDefined; 1.113 + bool IsLastWriteTimeDefined; 1.114 + bool IsLastAccessTimeDefined; 1.115 + bool IsStartPosDefined; 1.116 + 1.117 + /* 1.118 + const bool HasStream() const { 1.119 + return !IsDirectory && !IsAnti && UnPackSize != 0; } 1.120 + */ 1.121 + CFileItem(): 1.122 + HasStream(true), 1.123 + IsDirectory(false), 1.124 + IsAnti(false), 1.125 + IsFileCRCDefined(false), 1.126 + AreAttributesDefined(false), 1.127 + IsCreationTimeDefined(false), 1.128 + IsLastWriteTimeDefined(false), 1.129 + IsLastAccessTimeDefined(false), 1.130 + IsStartPosDefined(false) 1.131 + {} 1.132 + void SetAttributes(UInt32 attributes) 1.133 + { 1.134 + AreAttributesDefined = true; 1.135 + Attributes = attributes; 1.136 + } 1.137 + void SetCreationTime(const CArchiveFileTime &creationTime) 1.138 + { 1.139 + IsCreationTimeDefined = true; 1.140 + CreationTime = creationTime; 1.141 + } 1.142 + void SetLastWriteTime(const CArchiveFileTime &lastWriteTime) 1.143 + { 1.144 + IsLastWriteTimeDefined = true; 1.145 + LastWriteTime = lastWriteTime; 1.146 + } 1.147 + void SetLastAccessTime(const CArchiveFileTime &lastAccessTime) 1.148 + { 1.149 + IsLastAccessTimeDefined = true; 1.150 + LastAccessTime = lastAccessTime; 1.151 + } 1.152 +}; 1.153 + 1.154 +struct CArchiveDatabase 1.155 +{ 1.156 + CRecordVector<UInt64> PackSizes; 1.157 + CRecordVector<bool> PackCRCsDefined; 1.158 + CRecordVector<UInt32> PackCRCs; 1.159 + CObjectVector<CFolder> Folders; 1.160 + CRecordVector<CNum> NumUnPackStreamsVector; 1.161 + CObjectVector<CFileItem> Files; 1.162 + void Clear() 1.163 + { 1.164 + PackSizes.Clear(); 1.165 + PackCRCsDefined.Clear(); 1.166 + PackCRCs.Clear(); 1.167 + Folders.Clear(); 1.168 + NumUnPackStreamsVector.Clear(); 1.169 + Files.Clear(); 1.170 + } 1.171 + bool IsEmpty() const 1.172 + { 1.173 + return (PackSizes.IsEmpty() && 1.174 + PackCRCsDefined.IsEmpty() && 1.175 + PackCRCs.IsEmpty() && 1.176 + Folders.IsEmpty() && 1.177 + NumUnPackStreamsVector.IsEmpty() && 1.178 + Files.IsEmpty()); 1.179 + } 1.180 +}; 1.181 + 1.182 +}} 1.183 + 1.184 +#endif