xrootd
XrdZipZIP64EOCDL.hh
Go to the documentation of this file.
1 /*
2  * XrdZipZIP64EOCDL.hh
3  *
4  * Created on: 9 Nov 2020
5  * Author: simonm
6  */
7 
8 #ifndef SRC_XRDZIP_XRDZIPZIP64EOCDL_HH_
9 #define SRC_XRDZIP_XRDZIPZIP64EOCDL_HH_
10 
11 #include "XrdZip/XrdZipUtils.hh"
12 #include "XrdZip/XrdZipEOCD.hh"
14 #include <string>
15 #include <sstream>
16 
17 namespace XrdZip
18 {
19  //---------------------------------------------------------------------------
21  //---------------------------------------------------------------------------
22  struct ZIP64_EOCDL
23  {
24  //-------------------------------------------------------------------------
26  //-------------------------------------------------------------------------
27  ZIP64_EOCDL( const char *buffer )
28  {
29  nbDiskZip64Eocd = *reinterpret_cast<const uint32_t*>( buffer + 4 );
30  zip64EocdOffset = *reinterpret_cast<const uint64_t*>( buffer + 8 );
31  totalNbDisks = *reinterpret_cast<const uint32_t*>( buffer + 16 );
32  }
33 
34  //-------------------------------------------------------------------------
36  //-------------------------------------------------------------------------
37  ZIP64_EOCDL( const EOCD &eocd, const ZIP64_EOCD &zip64Eocd ):
38  nbDiskZip64Eocd( 0 ),
39  totalNbDisks( 1 )
40  {
41  if ( eocd.cdOffset == ovrflw<uint32_t>::value )
42  zip64EocdOffset = zip64Eocd.cdOffset;
43  else
45 
46  if ( eocd.cdSize == ovrflw<uint32_t>::value )
47  zip64EocdOffset += zip64Eocd.cdSize;
48  else
49  zip64EocdOffset += eocd.cdSize;
50  }
51 
52  //-------------------------------------------------------------------------
54  //-------------------------------------------------------------------------
55  void Serialize( buffer_t &buffer )
56  {
57  copy_bytes( zip64EocdlSign, buffer );
58  copy_bytes( nbDiskZip64Eocd, buffer );
59  copy_bytes( zip64EocdOffset, buffer );
60  copy_bytes( totalNbDisks, buffer );
61  }
62 
63  //-------------------------------------------------------------------------
65  //-------------------------------------------------------------------------
66  std::string ToString()
67  {
68  std::stringstream ss;
69  ss << "{nbDiskZip64Eocd=" << nbDiskZip64Eocd;
70  ss << ";zip64EocdOffset=" << zip64EocdOffset;
71  ss << ";totalNbDisks=" << totalNbDisks << "}";
72  return ss.str();
73  }
74 
75  uint32_t nbDiskZip64Eocd; //< number of the disk with the start of the zip64 end of central directory
76  uint64_t zip64EocdOffset; //< relative offset of the zip64 end of central directory record
77  uint32_t totalNbDisks; //< total number of disks
78 
79  //-------------------------------------------------------------------------
80  // the End of Central Directory locator signature
81  //-------------------------------------------------------------------------
82  static const uint32_t zip64EocdlSign = 0x07064b50;
83  static const uint16_t zip64EocdlSize = 20;
84  };
85 }
86 
87 #endif /* SRC_XRDZIP_XRDZIPZIP64EOCDL_HH_ */
uint64_t cdSize
Definition: XrdZipZIP64EOCD.hh:109
std::vector< char > buffer_t
Definition: XrdZipUtils.hh:54
std::string ToString()
Convert the EOCDL into a string for logging purposes.
Definition: XrdZipZIP64EOCDL.hh:66
static void copy_bytes(const INT value, buffer_t &buffer)
Definition: XrdZipUtils.hh:60
ZIP64_EOCDL(const char *buffer)
Constructor from a buffer.
Definition: XrdZipZIP64EOCDL.hh:27
uint32_t cdSize
Definition: XrdZipEOCD.hh:140
static const uint32_t zip64EocdlSign
Definition: XrdZipZIP64EOCDL.hh:82
uint32_t cdOffset
Definition: XrdZipEOCD.hh:141
static const uint16_t zip64EocdlSize
Definition: XrdZipZIP64EOCDL.hh:83
uint32_t totalNbDisks
Definition: XrdZipZIP64EOCDL.hh:77
void Serialize(buffer_t &buffer)
Serialize the object into a buffer.
Definition: XrdZipZIP64EOCDL.hh:55
ZIP64_EOCDL(const EOCD &eocd, const ZIP64_EOCD &zip64Eocd)
Constructor from EOCD and ZIP64 EOCD.
Definition: XrdZipZIP64EOCDL.hh:37
Definition: XrdZipCDFH.hh:39
uint32_t nbDiskZip64Eocd
Definition: XrdZipZIP64EOCDL.hh:75
Definition: XrdZipUtils.hh:46
A data structure representing the ZIP64 end of central directory locator.
Definition: XrdZipZIP64EOCDL.hh:22
Definition: XrdZipZIP64EOCD.hh:23
Definition: XrdZipEOCD.hh:39
uint64_t cdOffset
Definition: XrdZipZIP64EOCD.hh:110
uint64_t zip64EocdOffset
Definition: XrdZipZIP64EOCDL.hh:76