zipios
2.2.0
Zipios -- a small C++ library that provides easy access to .zip files.
|
Go to the documentation of this file.
310 uint32_t start_offset;
312 std::ifstream ifs(name, std::ios::in | std::ios::binary);
313 ifs.seekg(-4, std::ios::end);
357 std::ifstream zipfile(
m_filename, std::ios::in | std::ios::binary);
360 throw IOException(
"Error opening Zip archive file for reading in binary mode.");
380 if(eocd.
read(bb, read_p))
397 size_t const max_entry(eocd.
getCount());
398 for(
size_t entry_num(0); entry_num < max_entry; ++entry_num)
401 m_entries[entry_num].get()->read(zipfile);
411 throw FileCollectionException(
"Zip file consistency problem. Zip file data fields are inconsistent with zip file layout.");
425 m_vs.
vseekg(zipfile, (*it)->getEntryOffset(), std::ios::beg);
428 if(!zipfile || !zlh.
isEqual(**it))
430 throw FileCollectionException(
"Zip file consistency problem. Zip file data fields are inconsistent with zip file layout.");
534 if(!(*it)->isDirectory())
539 output_stream << is->rdbuf();
548 output_stream.
close();
552 os.setstate(std::ios::failbit);
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
virtual pointer_t clone() const override
Create a clone of this ZipFile.
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
void putNextEntry(FileEntry::pointer_t entry)
Add an entry to the output stream.
static void saveCollectionToArchive(std::ostream &os, FileCollection &collection, std::string const &zip_comment="")
Create a Zip archive from the specified FileCollection.
A specialization of ZipLocalEntry for.
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
To read a file by chunk from the end.
size_t getCentralDirectorySize() const
Retrieve the size of the Central Directory in bytes.
void close()
Close the current stream.
Define the zipios::ZipFile class.
virtual void mustBeValid() const
Check whether the collection is valid.
void finish()
Finish up the output by flushing anything left.
Various exceptions used throughout the Zipios library, all based on zipios::Exception.
void vseekg(std::istream &is, offset_t offset, std::ios::seekdir sd) const
Seek within the embedded file.
ssize_t readChunk(ssize_t &read_pointer)
Read a chunk of data.
void setComment(std::string const &comment)
Set the global comment.
std::shared_ptr< FileEntry > pointer_t
Define the zipios::ZipOutputStream class.
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH)=0
Retrieve pointer to an istream.
ZipFile()
Initialize a ZipFile object.
size_t getCount() const
Retrieve the number of entries.
An IOException is used to signal an I/O error.
std::streampos vtellg(std::istream &is) const
Current position within the sub-file.
Declaration of the zipios::ZipCentralDirectoryEntry, which represents a directory Zip archive entry.
Base class for various file collections.
static pointer_t openEmbeddedZipFile(std::string const &name)
Open a zip archive that was previously appended to another file.
virtual ~ZipFile() override
Clean up the ZipFile object.
FileCollectionException is used to signal a FileCollection problem.
virtual void close()
Close the current FileEntry of this FileCollection.
An implementation of the FileEntry for Zip archives.
virtual void read(std::istream &is) override
Read one local entry from is.
A ZipOutputStream to allow for data to be compressed zlib.
offset_t startOffset() const
Return the start offset.
virtual bool isEqual(FileEntry const &file_entry) const override
Compare two file entries for equality.
bool read(::zipios::buffer_t const &buf, size_t pos)
Attempt to read an ZipEndOfCentralDirectory structure.
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH) override
Retrieve a pointer to a file in the Zip archive.
FileEntry::vector_t m_entries
void zipRead(std::istream &is, uint32_t &value)
The header file for zipios::BackBuffer.
std::shared_ptr< FileCollection > pointer_t
Marker at the end of a Zip archive file.
Declaration of the zipios::ZipEndOfCentralDirectory class.
offset_t getOffset() const
Retrieve the offset of the Central Directory.
std::vector< pointer_t > vector_t
The zipios namespace includes the Zipios library definitions.