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