XRootD
Loading...
Searching...
No Matches
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.
 
 EOCD (uint64_t cdoff, uint32_t cdcnt, uint32_t cdsize)
 Constructor from last LFH + CDFH.
 
void Serialize (buffer_t &buffer)
 Serialize the object into a buffer.
 
std::string ToString ()
 Convert the EOCD into a string for logging purposes.
 

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 }
static INT to(const char *buffer)
uint16_t nbDisk
static const uint16_t eocdBaseSize
uint16_t eocdSize
std::string comment
uint16_t commentLength
uint16_t nbCdRecD
uint16_t nbDiskCd
uint32_t cdOffset
uint32_t cdSize
uint16_t nbCdRec

References cdOffset, cdSize, comment, commentLength, eocdBaseSize, eocdSize, nbCdRec, nbCdRecD, nbDisk, nbDiskCd, XrdZip::to(), and useZip64.

+ Here is the call graph for this function:

◆ 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

References cdOffset, cdSize, commentLength, eocdBaseSize, eocdSize, nbCdRec, nbCdRecD, nbDisk, nbDiskCd, useZip64, and XrdZip::ovrflw< UINT >::value.

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

References eocdBaseSize, eocdSign, and XrdZip::to().

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

+ Here is the call graph for this function:
+ 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)

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(), 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(), 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(), EOCD(), Serialize(), and ToString().

◆ eocdBaseSize

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

Definition at line 153 of file XrdZipEOCD.hh.

Referenced by EOCD(), 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(), and 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(), EOCD(), Serialize(), and ToString().

◆ nbCdRecD

uint16_t XrdZip::EOCD::nbCdRecD

Definition at line 140 of file XrdZipEOCD.hh.

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

◆ nbDisk

uint16_t XrdZip::EOCD::nbDisk

Definition at line 138 of file XrdZipEOCD.hh.

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

◆ nbDiskCd

uint16_t XrdZip::EOCD::nbDiskCd

Definition at line 139 of file XrdZipEOCD.hh.

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

◆ useZip64

bool XrdZip::EOCD::useZip64

Definition at line 147 of file XrdZipEOCD.hh.

Referenced by EOCD(), and EOCD().


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