Loading...
Searching...
No Matches
XrdZip::CDFH Struct Reference

`#include <XrdZipCDFH.hh>`

Collaboration diagram for XrdZip::CDFH:

## Public Member Functions

| CDFH (const char *buffer, const uint32_t maxSize=0)
| CDFH (LFH *lfh, mode_t mode, uint64_t lfhOffset)
bool | HasDataDescriptor ()
bool | IsZIP64 () const
void | ParseExtra (const char *buffer, uint16_t length)
void | Serialize (buffer_t &buffer)
| Serialize the object into a buffer.

## Static Public Member Functions

static size_t | CalcSize (const cdvec_t &cdvec, uint32_t orgcdsz, uint32_t orgcdcnt)
static uint64_t | GetOffset (const CDFH &cdfh)
static std::tuple< cdvec_t, cdmap_t > | Parse (const char *&buffer, uint32_t bufferSize)
static std::tuple< cdvec_t, cdmap_t > | Parse (const char *buffer, uint32_t bufferSize, uint16_t nbCdRecords)
static void | Serialize (uint32_t orgcdcnt, const buffer_t &orgcdbuf, const cdvec_t &cdvec, buffer_t &buffer)

## Public Attributes

uint16_t | cdfhSize
std::string | comment
uint16_t | commentLength
uint32_t | compressedSize
uint16_t | compressionMethod
uint32_t | externAttr
std::unique_ptr< Extra > | extra
uint16_t | extraLength
std::string | filename
uint16_t | filenameLength
uint16_t | generalBitFlag
uint16_t | internAttr
uint16_t | minZipVersion
uint16_t | nbDisk
uint32_t | offset
dos_timestmp | timestmp
uint32_t | uncompressedSize
uint32_t | ZCRC32
uint16_t | zipVersion

## Static Public Attributes

static const uint16_t | cdfhBaseSize = 46
static const uint32_t | cdfhSign = 0x02014b50

## Detailed Description

Definition at line 66 of file XrdZipCDFH.hh.

## Constructor & Destructor Documentation

## CDFH() [1/2]

XrdZip::CDFH::CDFH | ( | LFH * | lfh,
|  | mode_t | mode,
|  | uint64_t | lfhOffset )

inline

Definition at line 161 of file XrdZipCDFH.hh.

:
zipVersion( ( 3 << 8 ) | 63 ),
generalBitFlag( lfh->generalBitFlag ),
compressionMethod( lfh->compressionMethod ),
timestmp( lfh->timestmp ),
ZCRC32( lfh->ZCRC32 ),
compressedSize( lfh->compressedSize ),
uncompressedSize( lfh->uncompressedSize ),
filenameLength( lfh->filenameLength ),
commentLength( 0 ),
nbDisk( 0 ),
internAttr( 0 ),
externAttr( mode << 16 ),
filename( lfh->filename ),
extra( new Extra( lfh->extra.get(), lfhOffset ) )
{
if ( lfhOffset >= ovrflw<uint32_t>::value )
offset = ovrflw<uint32_t>::value;
else
offset = lfhOffset;
extraLength = extra->totalSize;
if ( extraLength == 0 )
minZipVersion = 10;
else
minZipVersion = 45;
cdfhSize = cdfhBaseSize + filenameLength + extraLength + commentLength;
}
XrdZip::CDFH::uncompressedSize
uint32_t uncompressedSize
Definition XrdZipCDFH.hh:336
XrdZip::CDFH::offset
uint32_t offset
Definition XrdZipCDFH.hh:343
XrdZip::CDFH::cdfhSize
uint16_t cdfhSize
Definition XrdZipCDFH.hh:347
XrdZip::CDFH::nbDisk
uint16_t nbDisk
Definition XrdZipCDFH.hh:340
XrdZip::CDFH::extra
std::unique_ptr< Extra > extra
Definition XrdZipCDFH.hh:345
XrdZip::CDFH::internAttr
uint16_t internAttr
Definition XrdZipCDFH.hh:341
XrdZip::CDFH::filename
std::string filename
Definition XrdZipCDFH.hh:344
XrdZip::CDFH::externAttr
uint32_t externAttr
Definition XrdZipCDFH.hh:342
XrdZip::CDFH::zipVersion
uint16_t zipVersion
Definition XrdZipCDFH.hh:329
XrdZip::CDFH::cdfhBaseSize
static const uint16_t cdfhBaseSize
Definition XrdZipCDFH.hh:353
XrdZip::CDFH::extraLength
uint16_t extraLength
Definition XrdZipCDFH.hh:338
XrdZip::CDFH::compressionMethod
uint16_t compressionMethod
Definition XrdZipCDFH.hh:332
XrdZip::CDFH::generalBitFlag
uint16_t generalBitFlag
Definition XrdZipCDFH.hh:331
XrdZip::CDFH::ZCRC32
uint32_t ZCRC32
Definition XrdZipCDFH.hh:334
XrdZip::CDFH::commentLength
uint16_t commentLength
Definition XrdZipCDFH.hh:339
XrdZip::CDFH::minZipVersion
uint16_t minZipVersion
Definition XrdZipCDFH.hh:330
XrdZip::CDFH::compressedSize
uint32_t compressedSize
Definition XrdZipCDFH.hh:335
XrdZip::CDFH::filenameLength
uint16_t filenameLength
Definition XrdZipCDFH.hh:337
XrdZip::CDFH::timestmp
dos_timestmp timestmp
Definition XrdZipCDFH.hh:333
XrdZip::ovrflw::value
static const UINT value
Definition XrdZipUtils.hh:50

References cdfhBaseSize, cdfhSize, commentLength, compressedSize, compressionMethod, externAttr, extra, extraLength, filename, filenameLength, generalBitFlag, internAttr, minZipVersion, nbDisk, offset, timestmp, uncompressedSize, XrdZip::ovrflw< UINT >::value, ZCRC32, and zipVersion.

Referenced by CalcSize(), GetOffset(), Parse(), Parse(), and Serialize().

Here is the caller graph for this function:

## CDFH() [2/2]

XrdZip::CDFH::CDFH | ( | const char * | buffer,
|  | const uint32_t | maxSize = 0 )

inline

Definition at line 195 of file XrdZipCDFH.hh.

{
zipVersion = to<uint16_t>(buffer + 4);
minZipVersion = to<uint16_t>(buffer + 6);
generalBitFlag = to<uint16_t>(buffer + 8);
compressionMethod = to<uint16_t>(buffer + 10);
timestmp.time = to<uint16_t>(buffer + 12);
timestmp.date = to<uint16_t>(buffer + 14);
ZCRC32 = to<uint32_t>(buffer + 16);
compressedSize = to<uint32_t>(buffer + 20);
uncompressedSize = to<uint32_t>(buffer + 24);
filenameLength = to<uint16_t>(buffer + 28);
extraLength = to<uint16_t>(buffer + 30);
commentLength = to<uint16_t>(buffer + 32);
nbDisk = to<uint16_t>(buffer + 34);
internAttr = to<uint16_t>(buffer + 36);
externAttr = to<uint32_t>(buffer + 38);
offset = to<uint32_t>(buffer + 42);
if(maxSize > 0 && (uint32_t)(cdfhBaseSize+filenameLength + extraLength + commentLength) > maxSize){
throw bad_data();
}
filename.assign( buffer + 46, filenameLength );
// now parse the 'extra' (may contain the zip64 extension to CDFH)
ParseExtra( buffer + 46 + filenameLength, extraLength );
cdfhSize = cdfhBaseSize + filenameLength + extraLength + commentLength;
}
XrdZip::to
static INT to(const char *buffer)
Definition XrdZipUtils.hh:91
XrdZip::CDFH::ParseExtra
void ParseExtra(const char *buffer, uint16_t length)
Definition XrdZipCDFH.hh:237

References cdfhBaseSize, cdfhSize, commentLength, compressedSize, compressionMethod, externAttr, extraLength, filename, filenameLength, generalBitFlag, internAttr, minZipVersion, nbDisk, offset, ParseExtra(), timestmp, XrdZip::to(), uncompressedSize, ZCRC32, and zipVersion.

Here is the call graph for this function:

## Member Function Documentation

## CalcSize()

size_t XrdZip::CDFH::CalcSize | ( | const cdvec_t & | cdvec,
|  | uint32_t | orgcdsz,
|  | uint32_t | orgcdcnt )

inline static

Definition at line 132 of file XrdZipCDFH.hh.

{
size_t size = 0;
auto itr = cdvec.begin() + orgcdcnt;
for( ; itr != cdvec.end() ; ++itr )
{
CDFH *cdfh = itr->get();
size += cdfh->cdfhSize;
}
return size + orgcdsz;
}
XrdZip::CDFH::CDFH
CDFH(LFH *lfh, mode_t mode, uint64_t lfhOffset)
Definition XrdZipCDFH.hh:161

References CDFH(), and cdfhSize.

Here is the call graph for this function:

## GetOffset()

uint64_t XrdZip::CDFH::GetOffset | ( | const CDFH & | cdfh | ) |

inline static

Definition at line 227 of file XrdZipCDFH.hh.

{
if( cdfh.offset != ovrflw<uint32_t>::value )
return cdfh.offset;
return cdfh.extra->offset;
}

References CDFH(), extra, offset, and XrdZip::ovrflw< UINT >::value.

Referenced by XrdCl::ZipArchive::ReadFromImpl.

Here is the call graph for this function:
Here is the caller graph for this function:

## HasDataDescriptor()

bool XrdZip::CDFH::HasDataDescriptor | ( |  | ) |

inline

Returns
  : true if the data descriptor flag is on, false otherwise

Definition at line 324 of file XrdZipCDFH.hh.

{
return generalBitFlag & DataDescriptor::flag;
}
XrdZip::DataDescriptor::flag
static const uint16_t flag
Definition XrdZipDataDescriptor.hh:43

References XrdZip::DataDescriptor::flag, and generalBitFlag.

Referenced by XrdCl::ZipArchive::GetOffset(), and XrdCl::ZipArchive::ReadFromImpl.

Here is the caller graph for this function:

## IsZIP64()

bool XrdZip::CDFH::IsZIP64 | ( |  | ) | const

inline

Returns
  : true if ZIP64 extension is present, false otherwise

Definition at line 316 of file XrdZipCDFH.hh.

{
return extra.get();
}

References extra.

Referenced by XrdCl::ZipArchive::GetOffset(), and XrdCl::ZipArchive::ReadFromImpl.

Here is the caller graph for this function:

## Parse() [1/2]

std::tuple< cdvec_t, cdmap_t > XrdZip::CDFH::Parse | ( | const char *& | buffer,
|  | uint32_t | bufferSize )

inline static

Definition at line 105 of file XrdZipCDFH.hh.

{
cdvec_t cdvec;
cdmap_t cdmap;
size_t i = 0;
while( bufferSize > 0 )
{
if( bufferSize < sizeof( uint32_t ) ) throw bad_data();
// check the signature
uint32_t signature = to<uint32_t>( buffer );
if( signature != cdfhSign )
return std::make_tuple( std::move( cdvec ), std::move( cdmap ) );
// parse the record
std::unique_ptr<CDFH> cdfh( new CDFH( buffer ) );
if( bufferSize < cdfh->cdfhSize ) throw bad_data();
buffer += cdfh->cdfhSize;
bufferSize -= cdfh->cdfhSize;
cdmap[cdfh->filename] = i++;
cdvec.push_back( std::move( cdfh ) );
}
return std::make_tuple( std::move( cdvec ), std::move( cdmap ) );
}
XrdZip::cdvec_t
std::vector< std::unique_ptr< CDFH > > cdvec_t
Definition XrdZipCDFH.hh:51
XrdZip::cdmap_t
std::unordered_map< std::string, size_t > cdmap_t
Definition XrdZipCDFH.hh:56
XrdZip::CDFH::cdfhSign
static const uint32_t cdfhSign
Definition XrdZipCDFH.hh:352

References CDFH(), cdfhSign, cdfhSize, and XrdZip::to().

Here is the call graph for this function:

## Parse() [2/2]

std::tuple< cdvec_t, cdmap_t > XrdZip::CDFH::Parse | ( | const char * | buffer,
|  | uint32_t | bufferSize,
|  | uint16_t | nbCdRecords )

inline static

Definition at line 75 of file XrdZipCDFH.hh.

{
uint32_t offset = 0;
cdvec_t cdvec;
cdmap_t cdmap;
cdvec.reserve( nbCdRecords );
for( size_t i = 0; i < nbCdRecords; ++i )
{
if( bufferSize < cdfhBaseSize ) break;
// check the signature
uint32_t signature = to<uint32_t>( buffer + offset );
if( signature != cdfhSign ) throw bad_data();
// parse the record
std::unique_ptr<CDFH> cdfh( new CDFH( buffer + offset, bufferSize ) );
offset += cdfh->cdfhSize;
bufferSize -= cdfh->cdfhSize;
cdmap[cdfh->filename] = i;
cdvec.push_back( std::move( cdfh ) );
}
return std::make_tuple( std::move( cdvec ), std::move( cdmap ) );
}

References CDFH(), cdfhBaseSize, cdfhSign, offset, and XrdZip::to().

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

Here is the call graph for this function:
Here is the caller graph for this function:

## ParseExtra()

void XrdZip::CDFH::ParseExtra | ( | const char * | buffer,
|  | uint16_t | length )

inline

Definition at line 237 of file XrdZipCDFH.hh.

{
uint8_t ovrflws = Extra::NONE;
uint16_t exsize = 0;
// check if compressed size is overflown
if( compressedSize == ovrflw<uint32_t>::value)
{
ovrflws |= Extra::CPMSIZE;
exsize += sizeof( uint64_t );
}
// check if original size is overflown
if( uncompressedSize == ovrflw<uint32_t>::value )
{
ovrflws |= Extra::UCMPSIZE;
exsize += sizeof( uint64_t );
}
// check if offset is overflown
if( offset == ovrflw<uint32_t>::value )
{
ovrflws |= Extra::OFFSET;
exsize += sizeof( uint64_t );
}
// check if number of disks is overflown
if( nbDisk == ovrflw<uint16_t>::value )
{
ovrflws |= Extra::NBDISK;
exsize += sizeof( uint32_t );
}
// if the expected size of ZIP64 extension is 0 we
// can skip parsing of 'extra'
if( exsize == 0 ) return;
// Parse the extra part
buffer = Extra::Find( buffer, length );
if( buffer )
{
extra.reset( new Extra() );
extra->FromBuffer( buffer, exsize, ovrflws );
}
}
XrdZip::Extra::Find
static const char * Find(const char *buffer, uint16_t length)
Definition XrdZipExtra.hh:101
XrdZip::Extra::CPMSIZE
@ CPMSIZE
Definition XrdZipExtra.hh:164
XrdZip::Extra::UCMPSIZE
@ UCMPSIZE
Definition XrdZipExtra.hh:163
XrdZip::Extra::NONE
@ NONE
Definition XrdZipExtra.hh:162
XrdZip::Extra::OFFSET
@ OFFSET
Definition XrdZipExtra.hh:165
XrdZip::Extra::NBDISK
@ NBDISK
Definition XrdZipExtra.hh:166

References compressedSize, XrdZip::Extra::CPMSIZE, extra, XrdZip::Extra::Find(), XrdZip::Extra::NBDISK, nbDisk, XrdZip::Extra::NONE, XrdZip::Extra::OFFSET, offset, XrdZip::Extra::UCMPSIZE, uncompressedSize, and XrdZip::ovrflw< UINT >::value.

Referenced by CDFH().

Here is the call graph for this function:
Here is the caller graph for this function:

## Serialize() [1/2]

void XrdZip::CDFH::Serialize | ( | buffer_t & | buffer | ) |

inline

Serialize the object into a buffer.

Definition at line 286 of file XrdZipCDFH.hh.

{
copy_bytes( cdfhSign, buffer );
copy_bytes( zipVersion, buffer );
copy_bytes( minZipVersion, buffer );
copy_bytes( generalBitFlag, buffer );
copy_bytes( compressionMethod, buffer );
copy_bytes( timestmp.time, buffer );
copy_bytes( timestmp.date, buffer );
copy_bytes( ZCRC32, buffer );
copy_bytes( compressedSize, buffer );
copy_bytes( uncompressedSize, buffer );
copy_bytes( filenameLength, buffer );
copy_bytes( extraLength, buffer );
copy_bytes( commentLength, buffer );
copy_bytes( nbDisk, buffer );
copy_bytes( internAttr, buffer );
copy_bytes( externAttr, buffer );
copy_bytes( offset, buffer );
std::copy( filename.begin(), filename.end(), std::back_inserter( buffer ) );
if( extra )
extra->Serialize( buffer );
if ( commentLength > 0 )
std::copy( comment.begin(), comment.end(), std::back_inserter( buffer ) );
}
XrdZip::copy_bytes
static void copy_bytes(const INT value, buffer_t &buffer)
Definition XrdZipUtils.hh:62
XrdZip::CDFH::comment
std::string comment
Definition XrdZipCDFH.hh:346

References cdfhSign, comment, commentLength, compressedSize, compressionMethod, XrdZip::copy_bytes(), externAttr, extra, extraLength, filename, filenameLength, generalBitFlag, internAttr, minZipVersion, nbDisk, offset, timestmp, uncompressedSize, ZCRC32, and zipVersion.

Here is the call graph for this function:

## Serialize() [2/2]

void XrdZip::CDFH::Serialize | ( | uint32_t | orgcdcnt,
|  | const buffer_t & | orgcdbuf,
|  | const cdvec_t & | cdvec,
|  | buffer_t & | buffer )

inline static

Definition at line 144 of file XrdZipCDFH.hh.

{
std::copy( orgcdbuf.begin(), orgcdbuf.end(), std::back_inserter( buffer ) );
auto itr = cdvec.begin() + orgcdcnt;
for( ; itr != cdvec.end() ; ++itr )
{
CDFH *cdfh = itr->get();
cdfh->Serialize( buffer );
}
}

References CDFH(), and Serialize().

Referenced by Serialize().

Here is the call graph for this function:
Here is the caller graph for this function:

## Member Data Documentation

## cdfhBaseSize

const uint16_t XrdZip::CDFH::cdfhBaseSize = 46

static

Definition at line 353 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Parse().

## cdfhSign

const uint32_t XrdZip::CDFH::cdfhSign = 0x02014b50

static

Definition at line 352 of file XrdZipCDFH.hh.

Referenced by Parse(), Parse(), and Serialize().

## cdfhSize

uint16_t XrdZip::CDFH::cdfhSize

Definition at line 347 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), CalcSize(), and Parse().

## comment

std::string XrdZip::CDFH::comment

Definition at line 346 of file XrdZipCDFH.hh.

Referenced by Serialize().

## commentLength

uint16_t XrdZip::CDFH::commentLength

Definition at line 339 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## compressedSize

uint32_t XrdZip::CDFH::compressedSize

Definition at line 335 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), XrdCl::ZipArchive::GetOffset(), ParseExtra(), XrdCl::ZipArchive::ReadFromImpl, and Serialize().

## compressionMethod

uint16_t XrdZip::CDFH::compressionMethod

Definition at line 332 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), XrdCl::ZipArchive::GetOffset(), XrdCl::ZipArchive::ReadFromImpl, and Serialize().

## externAttr

uint32_t XrdZip::CDFH::externAttr

Definition at line 342 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## extra

std::unique_ptr<Extra> XrdZip::CDFH::extra

Definition at line 345 of file XrdZipCDFH.hh.

Referenced by CDFH(), XrdCl::ZipArchive::GetOffset(), GetOffset(), IsZIP64(), XrdCl::ZipArchive::List(), ParseExtra(), XrdCl::ZipArchive::ReadFromImpl, and Serialize().

## extraLength

uint16_t XrdZip::CDFH::extraLength

Definition at line 338 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## filename

std::string XrdZip::CDFH::filename

Definition at line 344 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), XrdCl::ZipArchive::List(), and Serialize().

## filenameLength

uint16_t XrdZip::CDFH::filenameLength

Definition at line 337 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## generalBitFlag

uint16_t XrdZip::CDFH::generalBitFlag

Definition at line 331 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), HasDataDescriptor(), and Serialize().

## internAttr

uint16_t XrdZip::CDFH::internAttr

Definition at line 341 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## minZipVersion

uint16_t XrdZip::CDFH::minZipVersion

Definition at line 330 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## nbDisk

uint16_t XrdZip::CDFH::nbDisk

Definition at line 340 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), ParseExtra(), and Serialize().

## offset

uint32_t XrdZip::CDFH::offset

Definition at line 343 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), GetOffset(), Parse(), ParseExtra(), and Serialize().

## timestmp

dos_timestmp XrdZip::CDFH::timestmp

Definition at line 333 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## uncompressedSize

uint32_t XrdZip::CDFH::uncompressedSize

Definition at line 336 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), XrdCl::ZipArchive::List(), ParseExtra(), XrdCl::ZipArchive::ReadFromImpl, and Serialize().

## ZCRC32

uint32_t XrdZip::CDFH::ZCRC32

Definition at line 334 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

## zipVersion

uint16_t XrdZip::CDFH::zipVersion

Definition at line 329 of file XrdZipCDFH.hh.

Referenced by CDFH(), CDFH(), and Serialize().

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

- XrdZipCDFH.hh