68uint32_t
const g_signature = 0x06054b50;
83 : m_zip_comment(zip_comment)
229 ssize_t
const HEADER_SIZE(
static_cast<ssize_t
>(
sizeof(uint32_t) * 3 +
sizeof(uint16_t) * 5));
237 if(
static_cast<ssize_t
>(buf.size() - pos) < HEADER_SIZE)
245 if(signature != g_signature)
251 uint16_t disk_number;
252 uint16_t central_directory_entries;
253 uint16_t central_directory_total_entries;
254 uint32_t central_directory_size;
255 uint32_t central_directory_offset;
256 uint16_t comment_len;
258 zipRead(buf, pos, disk_number);
259 zipRead(buf, pos, disk_number);
260 zipRead(buf, pos, central_directory_entries);
261 zipRead(buf, pos, central_directory_total_entries);
262 zipRead(buf, pos, central_directory_size);
263 zipRead(buf, pos, central_directory_offset);
264 zipRead(buf, pos, comment_len);
269 if(central_directory_entries != central_directory_total_entries)
271 throw FileCollectionException(
"ZipEndOfCentralDirectory with a number of entries and total entries that differ is not supported, spanned zip files are not supported");
319#if INTPTR_MAX != INT32_MAX
327 uint16_t
const disk_number(0);
339 zipWrite(os, central_directory_entries);
340 zipWrite(os, central_directory_entries);
341 zipWrite(os, central_directory_size);
342 zipWrite(os, central_directory_offset);
FileCollectionException is used to signal a FileCollection problem.
Exception used when it is not possible to move forward.
std::string m_zip_comment
size_t getCentralDirectorySize() const
Retrieve the size of the Central Directory in bytes.
void setOffset(offset_t new_offset)
Offset of the Central Directory.
size_t getCount() const
Retrieve the number of entries.
offset_t getOffset() const
Retrieve the offset of the Central Directory.
size_t m_central_directory_entries
void write(std::ostream &os)
Write the ZipEndOfCentralDirectory structure to a stream.
bool read(::zipios::buffer_t const &buf, size_t pos)
Attempt to read an ZipEndOfCentralDirectory structure.
ZipEndOfCentralDirectory(std::string const &zip_comment=std::string())
Initialize an ZipEndOfCentralDirectory object.
offset_t m_central_directory_offset
void setCentralDirectorySize(size_t size)
Define the size of the central directory.
void setCount(size_t c)
Set the number of entries.
size_t m_central_directory_size
The zipios namespace includes the Zipios library definitions.
void zipRead(std::istream &is, uint32_t &value)
std::vector< unsigned char > buffer_t
A buffer of characters.
void zipWrite(std::ostream &os, uint32_t const &value)
Declaration of the zipios::ZipEndOfCentralDirectory class.
Various exceptions used throughout the Zipios library, all based on zipios::Exception.