1 // Archive/UdfIn.h -- UDF / ECMA-167
\r
3 #ifndef __ARCHIVE_UDF_IN_H
\r
4 #define __ARCHIVE_UDF_IN_H
\r
6 #include "Common/MyCom.h"
\r
7 #include "Common/IntToString.h"
\r
8 #include "Common/Buffer.h"
\r
9 #include "Common/MyString.h"
\r
10 #include "Common/MyMap.h"
\r
12 #include "../../IStream.h"
\r
14 namespace NArchive {
\r
17 // ---------- ECMA Part 1 ----------
\r
25 void Parse(const Byte *buf);
\r
26 // UString GetString() const;
\r
33 void Parse(const Byte *buf);
\r
34 UString GetString() const;
\r
40 void Parse(const Byte *p, unsigned size);
\r
41 UString GetString() const;
\r
51 unsigned GetType() const { return Data[1] >> 4; }
\r
52 bool IsLocal() const { return GetType() == 1; }
\r
53 int GetMinutesOffset() const
\r
55 int t = (Data[0] | ((UInt16)Data[1] << 8)) & 0xFFF;
\r
58 return (t > (60 * 24) || t < -(60 * 24)) ? 0 : t;
\r
60 unsigned GetYear() const { return (Data[2] | ((UInt16)Data[3] << 8)); }
\r
61 void Parse(const Byte *buf);
\r
74 void Parse(const Byte *buf);
\r
78 // ---------- ECMA Part 3: Volume Structure ----------
\r
86 // CRegId ContentsId;
\r
87 // Byte ContentsUse[128];
\r
88 // UInt32 AccessType;
\r
94 // Byte ImplUse[128];
\r
99 CPartition(): VolIndex(-1) {}
\r
101 // bool IsNsr() const { return (strncmp(ContentsId.Id, "+NSR0", 5) == 0); }
\r
102 // bool IsAllocated() const { return ((Flags & 1) != 0); }
\r
105 struct CLogBlockAddr
\r
108 UInt16 PartitionRef;
\r
110 void Parse(const Byte *buf);
\r
113 enum EShortAllocDescType
\r
115 SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated = 0,
\r
116 SHORT_ALLOC_DESC_TYPE_NotRecordedButAllocated = 1,
\r
117 SHORT_ALLOC_DESC_TYPE_NotRecordedAndNotAllocated = 2,
\r
118 SHORT_ALLOC_DESC_TYPE_NextExtent = 3
\r
121 struct CShortAllocDesc
\r
127 // UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
\r
128 // UInt32 GetType() const { return Len >> 30; }
\r
129 // bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
\r
130 void Parse(const Byte *buf);
\r
137 UInt32 UdfUniqueId;
\r
138 void Parse(const Byte *buf);
\r
142 struct CLongAllocDesc
\r
145 CLogBlockAddr Location;
\r
147 // Byte ImplUse[6];
\r
148 // CADImpUse adImpUse; // UDF
\r
150 UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
\r
151 UInt32 GetType() const { return Len >> 30; }
\r
152 bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
\r
153 void Parse(const Byte *buf);
\r
156 struct CPartitionMap
\r
162 // UInt16 VolSeqNumber;
\r
163 UInt16 PartitionNumber;
\r
167 int PartitionIndex;
\r
174 ICB_FILE_TYPE_DIR = 4,
\r
175 ICB_FILE_TYPE_FILE = 5
\r
178 enum EIcbDescriptorType
\r
180 ICB_DESC_TYPE_SHORT = 0,
\r
181 ICB_DESC_TYPE_LONG = 1,
\r
182 ICB_DESC_TYPE_EXTENDED = 2,
\r
183 ICB_DESC_TYPE_INLINE = 3
\r
188 // UInt32 PriorDirectNum;
\r
189 // UInt16 StrategyType;
\r
190 // UInt16 StrategyParam;
\r
191 // UInt16 MaxNumOfEntries;
\r
193 // CLogBlockAddr ParentIcb;
\r
196 bool IsDir() const { return FileType == ICB_FILE_TYPE_DIR; }
\r
197 int GetDescriptorType() const { return Flags & 3; }
\r
198 void Parse(const Byte *p);
\r
201 // const Byte FILEID_CHARACS_Existance = (1 << 0);
\r
202 const Byte FILEID_CHARACS_Parent = (1 << 3);
\r
206 // UInt16 FileVersion;
\r
207 // Byte FileCharacteristics;
\r
208 // CByteBuffer ImplUse;
\r
211 CFile(): /* FileVersion(0), FileCharacteristics(0), */ ItemIndex(-1) {}
\r
213 UString GetName() const { return Id.GetString(); }
\r
222 UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
\r
223 UInt32 GetType() const { return Len >> 30; }
\r
224 bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
\r
233 // UInt32 Permissions;
\r
234 // UInt16 FileLinkCount;
\r
235 // Byte RecordFormat;
\r
236 // Byte RecordDisplayAttr;
\r
237 // UInt32 RecordLen;
\r
239 UInt64 NumLogBlockRecorded;
\r
242 // CTime AttrtTime;
\r
243 // UInt32 CheckPoint;
\r
244 // CLongAllocDesc ExtendedAttrIcb;
\r
246 // UInt64 UniqueId;
\r
249 CByteBuffer InlineData;
\r
250 CRecordVector<CMyExtent> Extents;
\r
251 CRecordVector<int> SubFiles;
\r
253 void Parse(const Byte *buf);
\r
255 bool IsRecAndAlloc() const
\r
257 for (int i = 0; i < Extents.Size(); i++)
\r
258 if (!Extents[i].IsRecAndAlloc())
\r
263 UInt64 GetChunksSumSize() const
\r
266 return InlineData.GetCapacity();
\r
268 for (int i = 0; i < Extents.Size(); i++)
\r
269 size += Extents[i].GetLen();
\r
273 bool CheckChunkSizes() const { return GetChunksSumSize() == Size; }
\r
275 bool IsDir() const { return IcbTag.IsDir(); }
\r
288 CTime RecodringTime;
\r
289 // UInt16 InterchangeLevel;
\r
290 // UInt16 MaxInterchangeLevel;
\r
291 // UInt32 FileSetNumber;
\r
292 // UInt32 FileSetDescNumber;
\r
294 // CDString32 CopyrightId;
\r
295 // CDString32 AbstractId;
\r
297 CLongAllocDesc RootDirICB;
\r
298 // CRegId DomainId;
\r
299 // CLongAllocDesc SystemStreamDirICB;
\r
301 CRecordVector<CRef> Refs;
\r
311 // CRegId DomainId;
\r
313 // Byte ContentsUse[16];
\r
314 CLongAllocDesc FileSetLocation; // UDF
\r
317 // Byte ImplUse[128];
\r
319 CObjectVector<CPartitionMap> PartitionMaps;
\r
320 CObjectVector<CFileSet> FileSets;
\r
322 UString GetName() const { return Id.GetString(); }
\r
325 struct CProgressVirt
\r
327 virtual HRESULT SetTotal(UInt64 numBytes) PURE;
\r
328 virtual HRESULT SetCompleted(UInt64 numFiles, UInt64 numBytes) PURE;
\r
329 virtual HRESULT SetCompleted() PURE;
\r
334 CMyComPtr<IInStream> _stream;
\r
335 CProgressVirt *_progress;
\r
337 HRESULT Read(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len, Byte *buf);
\r
338 HRESULT Read(int volIndex, const CLongAllocDesc &lad, Byte *buf);
\r
339 HRESULT ReadFromFile(int volIndex, const CItem &item, CByteBuffer &buf);
\r
341 HRESULT ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
\r
342 HRESULT ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
\r
345 HRESULT FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed);
\r
347 UInt64 _processedProgressBytes;
\r
349 UInt64 _fileNameLengthTotal;
\r
351 UInt32 _numExtents;
\r
352 UInt64 _inlineExtentsSize;
\r
353 bool CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const;
\r
355 HRESULT Open(IInStream *inStream, CProgressVirt *progress);
\r
358 CObjectVector<CPartition> Partitions;
\r
359 CObjectVector<CLogVol> LogVols;
\r
361 CObjectVector<CItem> Items;
\r
362 CObjectVector<CFile> Files;
\r
366 UString GetComment() const;
\r
367 UString GetItemPath(int volIndex, int fsIndex, int refIndex,
\r
368 bool showVolName, bool showFsName) const;
\r
370 bool CheckItemExtents(int volIndex, const CItem &item) const;
\r