xrootd
Loading...
Searching...
No Matches
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
17namespace XrdZip
18{
19 //---------------------------------------------------------------------------
21 //---------------------------------------------------------------------------
23 {
24 //-------------------------------------------------------------------------
26 //-------------------------------------------------------------------------
27 ZIP64_EOCDL( const char *buffer )
28 {
29 nbDiskZip64Eocd = to<uint32_t>(buffer + 4);
30 zip64EocdOffset = to<uint64_t>(buffer + 8);
31 totalNbDisks = to<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 {
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_ */
Definition XrdZipCDFH.hh:42
std::vector< char > buffer_t
Definition XrdZipUtils.hh:56
static void copy_bytes(const INT value, buffer_t &buffer)
Definition XrdZipUtils.hh:62
Definition XrdZipEOCD.hh:40
uint32_t cdOffset
Definition XrdZipEOCD.hh:143
uint32_t cdSize
Definition XrdZipEOCD.hh:142
A data structure representing the ZIP64 end of central directory locator.
Definition XrdZipZIP64EOCDL.hh:23
static const uint32_t zip64EocdlSign
Definition XrdZipZIP64EOCDL.hh:82
static const uint16_t zip64EocdlSize
Definition XrdZipZIP64EOCDL.hh:83
void Serialize(buffer_t &buffer)
Serialize the object into a buffer.
Definition XrdZipZIP64EOCDL.hh:55
uint32_t totalNbDisks
Definition XrdZipZIP64EOCDL.hh:77
ZIP64_EOCDL(const char *buffer)
Constructor from a buffer.
Definition XrdZipZIP64EOCDL.hh:27
uint32_t nbDiskZip64Eocd
Definition XrdZipZIP64EOCDL.hh:75
ZIP64_EOCDL(const EOCD &eocd, const ZIP64_EOCD &zip64Eocd)
Constructor from EOCD and ZIP64 EOCD.
Definition XrdZipZIP64EOCDL.hh:37
std::string ToString()
Convert the EOCDL into a string for logging purposes.
Definition XrdZipZIP64EOCDL.hh:66
uint64_t zip64EocdOffset
Definition XrdZipZIP64EOCDL.hh:76
Definition XrdZipZIP64EOCD.hh:24
uint64_t cdSize
Definition XrdZipZIP64EOCD.hh:109
uint64_t cdOffset
Definition XrdZipZIP64EOCD.hh:110
Definition XrdZipUtils.hh:49