XRootD
XrdZip::EOCD Struct Reference

#include <XrdZipEOCD.hh>

+ Collaboration diagram for XrdZip::EOCD:

Public Member Functions

 EOCD (const char *buffer, uint32_t maxSize=0)
 Constructor from buffer. More...
 
 EOCD (uint64_t cdoff, uint32_t cdcnt, uint32_t cdsize)
 Constructor from last LFH + CDFH. More...
 
void Serialize (buffer_t &buffer)
 Serialize the object into a buffer. More...
 
std::string ToString ()
 Convert the EOCD into a string for logging purposes. More...
 

Static Public Member Functions

static const char * Find (const char *buffer, uint64_t size)
 

Public Attributes

uint32_t cdOffset
 
uint32_t cdSize
 
std::string comment
 
uint16_t commentLength
 
uint16_t eocdSize
 
uint16_t nbCdRec
 
uint16_t nbCdRecD
 
uint16_t nbDisk
 
uint16_t nbDiskCd
 
bool useZip64
 

Static Public Attributes

static const uint16_t eocdBaseSize = 22
 
static const uint32_t eocdSign = 0x06054b50
 
static const uint16_t maxCommentLength = 65535
 

Detailed Description

Definition at line 39 of file XrdZipEOCD.hh.

Constructor & Destructor Documentation

◆ EOCD() [1/2]

XrdZip::EOCD::EOCD ( const char *  buffer,
uint32_t  maxSize = 0 
)
inline

Constructor from buffer.

Definition at line 54 of file XrdZipEOCD.hh.

55  {
56  nbDisk = to<uint16_t>(buffer + 4);
57  nbDiskCd = to<uint16_t>(buffer + 6);
58  nbCdRecD = to<uint16_t>(buffer + 8);
59  nbCdRec = to<uint16_t>(buffer + 10);
60  cdSize = to<uint32_t>(buffer + 12);
61  cdOffset = to<uint32_t>(buffer + 16);
62  commentLength = to<uint16_t>(buffer + 20);
63  if(maxSize > 0 && (uint32_t)(eocdBaseSize + commentLength) > maxSize)
64  throw bad_data();
65  comment = std::string( buffer + 22, commentLength );
66 
68  useZip64= false;
69  }
uint16_t nbDisk
Definition: XrdZipEOCD.hh:138
static const uint16_t eocdBaseSize
Definition: XrdZipEOCD.hh:153
uint16_t eocdSize
Definition: XrdZipEOCD.hh:146
std::string comment
Definition: XrdZipEOCD.hh:145
uint16_t commentLength
Definition: XrdZipEOCD.hh:144
uint16_t nbCdRecD
Definition: XrdZipEOCD.hh:140
uint16_t nbDiskCd
Definition: XrdZipEOCD.hh:139
uint32_t cdOffset
Definition: XrdZipEOCD.hh:143
uint32_t cdSize
Definition: XrdZipEOCD.hh:142
uint16_t nbCdRec
Definition: XrdZipEOCD.hh:141

References cdOffset, cdSize, comment, commentLength, eocdBaseSize, eocdSize, nbCdRec, nbCdRecD, nbDisk, nbDiskCd, and useZip64.

◆ EOCD() [2/2]

XrdZip::EOCD::EOCD ( uint64_t  cdoff,
uint32_t  cdcnt,
uint32_t  cdsize 
)
inline

Constructor from last LFH + CDFH.

Definition at line 74 of file XrdZipEOCD.hh.

74  :
75  nbDisk( 0 ),
76  nbDiskCd( 0 ),
77  commentLength( 0 ),
78  useZip64( false )
79  {
80  if( cdcnt >= ovrflw<uint16_t>::value )
81  {
84  }
85  else
86  {
87  nbCdRecD = cdcnt;
88  nbCdRec = cdcnt;
89  }
90 
91  cdSize = cdsize;
92 
93  if( cdoff >= ovrflw<uint32_t>::value )
94  {
96  useZip64 = true;
97  }
98  else
99  cdOffset = cdoff;
100 
102  }
static const UINT value
Definition: XrdZipUtils.hh:50

References cdOffset, cdSize, commentLength, eocdBaseSize, eocdSize, nbCdRec, nbCdRecD, and useZip64.

Member Function Documentation

◆ Find()

static const char* XrdZip::EOCD::Find ( const char *  buffer,
uint64_t  size 
)
inlinestatic

Definition at line 41 of file XrdZipEOCD.hh.

42  {
43  for( ssize_t offset = size - eocdBaseSize; offset >= 0; --offset )
44  {
45  uint32_t signature = to<uint32_t>( buffer + offset );
46  if( signature == eocdSign ) return buffer + offset;
47  }
48  return 0;
49  }
static const uint32_t eocdSign
Definition: XrdZipEOCD.hh:152

References eocdBaseSize, and eocdSign.

Referenced by XrdCl::ZipArchive::OpenArchive().

+ Here is the caller graph for this function:

◆ Serialize()

void XrdZip::EOCD::Serialize ( buffer_t buffer)
inline

Serialize the object into a buffer.

Definition at line 107 of file XrdZipEOCD.hh.

108  {
109  copy_bytes( eocdSign, buffer );
110  copy_bytes( nbDisk, buffer );
111  copy_bytes( nbDiskCd, buffer );
112  copy_bytes( nbCdRecD, buffer );
113  copy_bytes( nbCdRec, buffer );
114  copy_bytes( cdSize, buffer );
115  copy_bytes( cdOffset, buffer );
116  copy_bytes( commentLength, buffer );
117 
118  std::copy( comment.begin(), comment.end(), std::back_inserter( buffer ) );
119  }
static void copy_bytes(const INT value, buffer_t &buffer)
Definition: XrdZipUtils.hh:62

References cdOffset, cdSize, comment, commentLength, XrdZip::copy_bytes(), eocdSign, nbCdRec, nbCdRecD, nbDisk, and nbDiskCd.

+ Here is the call graph for this function:

◆ ToString()

std::string XrdZip::EOCD::ToString ( )
inline

Convert the EOCD into a string for logging purposes.

Definition at line 124 of file XrdZipEOCD.hh.

125  {
126  std::stringstream ss;
127  ss << "{nbDisk=" << nbDisk;
128  ss << ";nbDiskCd=" << nbDiskCd;
129  ss << ";nbCdRecD=" << nbCdRecD;
130  ss << ";nbCdRec=" << nbCdRec;
131  ss << ";cdSize" << cdSize;
132  ss << ";cdOffset=" << cdOffset;
133  ss << ";commentLength=" << commentLength;
134  ss << ";comment=" << comment << '}';
135  return ss.str();
136  }

References cdOffset, cdSize, comment, commentLength, nbCdRec, nbCdRecD, nbDisk, and nbDiskCd.

Member Data Documentation

◆ cdOffset

uint32_t XrdZip::EOCD::cdOffset

Definition at line 143 of file XrdZipEOCD.hh.

Referenced by EOCD(), XrdZip::ZIP64_EOCDL::ZIP64_EOCDL(), Serialize(), and ToString().

◆ cdSize

uint32_t XrdZip::EOCD::cdSize

Definition at line 142 of file XrdZipEOCD.hh.

Referenced by EOCD(), XrdZip::ZIP64_EOCDL::ZIP64_EOCDL(), Serialize(), and ToString().

◆ comment

std::string XrdZip::EOCD::comment

Definition at line 145 of file XrdZipEOCD.hh.

Referenced by EOCD(), Serialize(), and ToString().

◆ commentLength

uint16_t XrdZip::EOCD::commentLength

Definition at line 144 of file XrdZipEOCD.hh.

Referenced by EOCD(), Serialize(), and ToString().

◆ eocdBaseSize

const uint16_t XrdZip::EOCD::eocdBaseSize = 22
static

Definition at line 153 of file XrdZipEOCD.hh.

Referenced by EOCD(), Find(), and XrdCl::ZipArchive::OpenArchive().

◆ eocdSign

const uint32_t XrdZip::EOCD::eocdSign = 0x06054b50
static

Definition at line 152 of file XrdZipEOCD.hh.

Referenced by Find(), and Serialize().

◆ eocdSize

uint16_t XrdZip::EOCD::eocdSize

Definition at line 146 of file XrdZipEOCD.hh.

Referenced by EOCD().

◆ maxCommentLength

const uint16_t XrdZip::EOCD::maxCommentLength = 65535
static

Definition at line 154 of file XrdZipEOCD.hh.

Referenced by XrdCl::ZipArchive::OpenArchive().

◆ nbCdRec

uint16_t XrdZip::EOCD::nbCdRec

Definition at line 141 of file XrdZipEOCD.hh.

Referenced by EOCD(), Serialize(), and ToString().

◆ nbCdRecD

uint16_t XrdZip::EOCD::nbCdRecD

Definition at line 140 of file XrdZipEOCD.hh.

Referenced by EOCD(), Serialize(), and ToString().

◆ nbDisk

uint16_t XrdZip::EOCD::nbDisk

Definition at line 138 of file XrdZipEOCD.hh.

Referenced by EOCD(), Serialize(), and ToString().

◆ nbDiskCd

uint16_t XrdZip::EOCD::nbDiskCd

Definition at line 139 of file XrdZipEOCD.hh.

Referenced by EOCD(), Serialize(), and ToString().

◆ useZip64

bool XrdZip::EOCD::useZip64

Definition at line 147 of file XrdZipEOCD.hh.

Referenced by EOCD().


The documentation for this struct was generated from the following file: