XRootD
Loading...
Searching...
No Matches
XrdZip::LFH Struct Reference

A data structure representing ZIP Local File Header. More...

#include <XrdZipLFH.hh>

+ Collaboration diagram for XrdZip::LFH:

Public Member Functions

 LFH (const char *buffer, const uint64_t bufferSize=0)
 Constructor from buffer.
 
 LFH (const std::string &filename, uint32_t crc, off_t fileSize, time_t time)
 Constructor.
 
void ParseExtra (const char *buffer, uint16_t length)
 
void Serialize (buffer_t &buffer)
 Serialize the object into a buffer.
 

Static Public Member Functions

static uint32_t initSize (const off_t &fileSize)
 Convenience function for initializing compressed/uncompressed size.
 

Public Attributes

uint32_t compressedSize
 
uint16_t compressionMethod
 
std::unique_ptr< Extraextra
 
uint16_t extraLength
 
std::string filename
 
uint16_t filenameLength
 
uint16_t generalBitFlag
 
uint16_t lfhSize
 
uint16_t minZipVersion
 
dos_timestmp timestmp
 
uint32_t uncompressedSize
 
uint32_t ZCRC32
 

Static Public Attributes

static const uint16_t lfhBaseSize = 30
 
static const uint32_t lfhSign = 0x04034b50
 Local File Header signature.
 

Detailed Description

A data structure representing ZIP Local File Header.

Definition at line 41 of file XrdZipLFH.hh.

Constructor & Destructor Documentation

◆ LFH() [1/2]

XrdZip::LFH::LFH ( const std::string & filename,
uint32_t crc,
off_t fileSize,
time_t time )
inline

Constructor.

Definition at line 55 of file XrdZipLFH.hh.

55 :
56 generalBitFlag( 0 ), compressionMethod( 0 ), timestmp( time ), ZCRC32( crc ),
57 compressedSize( initSize( fileSize ) ), uncompressedSize( initSize( fileSize ) ),
58 filenameLength( filename.size() ), filename( filename ), extra( new Extra( fileSize ) )
59 {
60 extraLength = extra->totalSize;
61 if ( extraLength == 0 )
62 minZipVersion = 10;
63 else
64 minZipVersion = 45;
66 }
uint32_t ZCRC32
Definition XrdZipLFH.hh:161
static const uint16_t lfhBaseSize
Definition XrdZipLFH.hh:174
dos_timestmp timestmp
Definition XrdZipLFH.hh:160
uint16_t extraLength
Definition XrdZipLFH.hh:165
uint32_t compressedSize
Definition XrdZipLFH.hh:162
static uint32_t initSize(const off_t &fileSize)
Convenience function for initializing compressed/uncompressed size.
Definition XrdZipLFH.hh:46
uint16_t compressionMethod
Definition XrdZipLFH.hh:159
uint16_t generalBitFlag
Definition XrdZipLFH.hh:158
uint16_t lfhSize
Definition XrdZipLFH.hh:168
std::unique_ptr< Extra > extra
Definition XrdZipLFH.hh:167
uint32_t uncompressedSize
Definition XrdZipLFH.hh:163
uint16_t minZipVersion
Definition XrdZipLFH.hh:157
std::string filename
Definition XrdZipLFH.hh:166
uint16_t filenameLength
Definition XrdZipLFH.hh:164

References compressedSize, compressionMethod, extra, extraLength, filename, filenameLength, generalBitFlag, initSize(), lfhBaseSize, lfhSize, minZipVersion, timestmp, uncompressedSize, and ZCRC32.

+ Here is the call graph for this function:

◆ LFH() [2/2]

XrdZip::LFH::LFH ( const char * buffer,
const uint64_t bufferSize = 0 )
inline

Constructor from buffer.

Definition at line 71 of file XrdZipLFH.hh.

72 {
73 if(bufferSize > 0 && bufferSize < (uint64_t)lfhBaseSize)
74 throw bad_data();
75 // check if the buffer contains a LFH record
76 uint32_t signature = 0;
77 from_buffer( signature, buffer );
78 if( signature != lfhSign ) throw bad_data();
79 // parse LFH filds
80 from_buffer( minZipVersion, buffer );
81 from_buffer( generalBitFlag, buffer );
83 from_buffer( timestmp.time, buffer );
84 from_buffer( timestmp.date, buffer );
85 from_buffer( ZCRC32, buffer );
86 from_buffer( compressedSize, buffer );
88 from_buffer( filenameLength, buffer );
89 from_buffer( extraLength, buffer );
90
91 if(bufferSize > 0 && (uint64_t)(lfhBaseSize + filenameLength + extraLength) > bufferSize)
92 throw bad_data();
93 // parse the filename
94 filename.assign( buffer, filenameLength );
95 buffer += filenameLength;
96 // parse the extra record
97 if( extraLength > 0 )
98 ParseExtra( buffer, extraLength );
99
101 }
static void from_buffer(INT &var, const char *&buffer)
void ParseExtra(const char *buffer, uint16_t length)
Definition XrdZipLFH.hh:126
static const uint32_t lfhSign
Local File Header signature.
Definition XrdZipLFH.hh:173

References compressedSize, compressionMethod, extraLength, filename, filenameLength, XrdZip::from_buffer(), generalBitFlag, lfhBaseSize, lfhSign, lfhSize, minZipVersion, ParseExtra(), timestmp, uncompressedSize, and ZCRC32.

+ Here is the call graph for this function:

Member Function Documentation

◆ initSize()

static uint32_t XrdZip::LFH::initSize ( const off_t & fileSize)
inlinestatic

Convenience function for initializing compressed/uncompressed size.

Definition at line 46 of file XrdZipLFH.hh.

47 {
48 return fileSize >= ovrflw<uint32_t>::value ?
49 ovrflw<uint32_t>::value : fileSize;
50 }
static const UINT value

References XrdZip::ovrflw< UINT >::value.

Referenced by LFH().

+ Here is the caller graph for this function:

◆ ParseExtra()

void XrdZip::LFH::ParseExtra ( const char * buffer,
uint16_t length )
inline

Definition at line 126 of file XrdZipLFH.hh.

127 {
128 uint8_t ovrflws = Extra::NONE;
129 uint16_t exsize = 0;
130
131 // check if compressed size is overflown
133 {
134 ovrflws |= Extra::CPMSIZE;
135 exsize += sizeof( uint64_t );
136 }
137
138 // check if original size is overflown
140 {
141 ovrflws |= Extra::UCMPSIZE;
142 exsize += sizeof( uint64_t );
143 }
144
145 // if the expected size of ZIP64 extension is 0 we
146 // can skip parsing of 'extra'
147 if( exsize == 0 ) return;
148
149 extra.reset( new Extra() );
150
151 // Parse the extra part
152 buffer = Extra::Find( buffer, length );
153 if( buffer )
154 extra->FromBuffer( buffer, exsize, ovrflws );
155 }
static const char * Find(const char *buffer, uint16_t length)

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

Referenced by LFH().

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

◆ Serialize()

void XrdZip::LFH::Serialize ( buffer_t & buffer)
inline

Serialize the object into a buffer.

Definition at line 106 of file XrdZipLFH.hh.

107 {
108 copy_bytes( lfhSign, buffer );
109 copy_bytes( minZipVersion, buffer );
110 copy_bytes( generalBitFlag, buffer );
111 copy_bytes( compressionMethod, buffer );
112 copy_bytes( timestmp.time, buffer );
113 copy_bytes( timestmp.date, buffer );
114 copy_bytes( ZCRC32, buffer );
115 copy_bytes( compressedSize, buffer );
116 copy_bytes( uncompressedSize, buffer );
117 copy_bytes( filenameLength, buffer );
118 copy_bytes( extraLength , buffer );
119 std::copy( filename.begin(), filename.end(), std::back_inserter( buffer ) );
120 extra->Serialize( buffer );
121 }
static void copy_bytes(const INT value, buffer_t &buffer)

References compressedSize, compressionMethod, XrdZip::copy_bytes(), extra, extraLength, filename, filenameLength, generalBitFlag, lfhSign, minZipVersion, timestmp, uncompressedSize, and ZCRC32.

+ Here is the call graph for this function:

Member Data Documentation

◆ compressedSize

uint32_t XrdZip::LFH::compressedSize

Definition at line 162 of file XrdZipLFH.hh.

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

◆ compressionMethod

uint16_t XrdZip::LFH::compressionMethod

Definition at line 159 of file XrdZipLFH.hh.

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

◆ extra

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

Definition at line 167 of file XrdZipLFH.hh.

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

◆ extraLength

uint16_t XrdZip::LFH::extraLength

Definition at line 165 of file XrdZipLFH.hh.

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

◆ filename

std::string XrdZip::LFH::filename

Definition at line 166 of file XrdZipLFH.hh.

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

◆ filenameLength

uint16_t XrdZip::LFH::filenameLength

Definition at line 164 of file XrdZipLFH.hh.

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

◆ generalBitFlag

uint16_t XrdZip::LFH::generalBitFlag

Definition at line 158 of file XrdZipLFH.hh.

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

◆ lfhBaseSize

const uint16_t XrdZip::LFH::lfhBaseSize = 30
static

Definition at line 174 of file XrdZipLFH.hh.

Referenced by LFH(), and LFH().

◆ lfhSign

const uint32_t XrdZip::LFH::lfhSign = 0x04034b50
static

Local File Header signature.

Definition at line 173 of file XrdZipLFH.hh.

Referenced by LFH(), and Serialize().

◆ lfhSize

uint16_t XrdZip::LFH::lfhSize

Definition at line 168 of file XrdZipLFH.hh.

Referenced by LFH(), and LFH().

◆ minZipVersion

uint16_t XrdZip::LFH::minZipVersion

Definition at line 157 of file XrdZipLFH.hh.

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

◆ timestmp

dos_timestmp XrdZip::LFH::timestmp

Definition at line 160 of file XrdZipLFH.hh.

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

◆ uncompressedSize

uint32_t XrdZip::LFH::uncompressedSize

Definition at line 163 of file XrdZipLFH.hh.

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

◆ ZCRC32

uint32_t XrdZip::LFH::ZCRC32

Definition at line 161 of file XrdZipLFH.hh.

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


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