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