zipios 2.3.4
Zipios -- a small C++ library providing easy access to .zip files.
zipoutputstream.cpp
Go to the documentation of this file.
1/*
2 Zipios -- a small C++ library that provides easy access to .zip files.
3
4 Copyright (C) 2000-2007 Thomas Sondergaard
5 Copyright (c) 2015-2022 Made to Order Software Corp. All Rights Reserved
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
29#include "zipoutputstream.hpp"
31
32#include <fstream>
33
34
35namespace zipios
36{
37
55 : m_ozf(std::make_unique<ZipOutputStreambuf>(os.rdbuf()))
56{
57 init(m_ozf.get());
58}
59
60
69
70
76{
77 m_ozf->closeEntry();
78}
79
80
90{
91 m_ozf->close();
92}
93
94
103{
104 m_ozf->finish();
105}
106
107
129{
130 // if we do not yet have a ZipCentralDirectoryEntry object, create
131 // one from the input entry (the input entry is actually expected
132 // to be a DirectoryEntry!)
133 ZipCentralDirectoryEntry * central_directory_entry(dynamic_cast<ZipCentralDirectoryEntry *>(entry.get()));
134 if(central_directory_entry == nullptr)
135 {
136 entry = std::make_shared<ZipCentralDirectoryEntry>(*entry);
137 }
138
139 m_ozf->putNextEntry(entry);
140}
141
142
153void ZipOutputStream::setComment(std::string const & comment)
154{
155 m_ozf->setComment(comment);
156}
157
158
159} // zipios namespace
160
161// Local Variables:
162// mode: cpp
163// indent-tabs-mode: nil
164// c-basic-offset: 4
165// tab-width: 4
166// End:
167
168// vim: ts=4 sw=4 et
std::shared_ptr< FileEntry > pointer_t
Definition fileentry.hpp:78
A specialization of ZipLocalEntry for.
void close()
Close the current stream.
ZipOutputStream(std::ostream &os)
Initialize a ZipOutputStream object.
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.
virtual ~ZipOutputStream()
Clean up a ZipOutputStream object.
std::unique_ptr< ZipOutputStreambuf > m_ozf
Handle the output buffer of a zip archive.
The zipios namespace includes the Zipios library definitions.
Declaration of the zipios::ZipCentralDirectoryEntry, which represents a directory Zip archive entry.
Define the zipios::ZipOutputStream class.