zipios
2.3.4
Zipios -- a small C++ library providing easy access to .zip files.
src
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
"
30
#include "
zipcentraldirectoryentry.hpp
"
31
32
#include <fstream>
33
34
35
namespace
zipios
36
{
37
54
ZipOutputStream::ZipOutputStream
(std::ostream & os)
55
: m_ozf(std::make_unique<
ZipOutputStreambuf
>(os.rdbuf()))
56
{
57
init(
m_ozf
.get());
58
}
59
60
66
ZipOutputStream::~ZipOutputStream
()
67
{
68
}
69
70
75
void
ZipOutputStream::closeEntry
()
76
{
77
m_ozf
->closeEntry();
78
}
79
80
89
void
ZipOutputStream::close
()
90
{
91
m_ozf
->close();
92
}
93
94
102
void
ZipOutputStream::finish
()
103
{
104
m_ozf
->finish();
105
}
106
107
128
void
ZipOutputStream::putNextEntry
(
FileEntry::pointer_t
entry)
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
153
void
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
zipios::FileEntry::pointer_t
std::shared_ptr< FileEntry > pointer_t
Definition
fileentry.hpp:78
zipios::ZipCentralDirectoryEntry
A specialization of ZipLocalEntry for.
Definition
zipcentraldirectoryentry.hpp:44
zipios::ZipOutputStream::closeEntry
void closeEntry()
Definition
zipoutputstream.cpp:75
zipios::ZipOutputStream::close
void close()
Close the current stream.
Definition
zipoutputstream.cpp:89
zipios::ZipOutputStream::ZipOutputStream
ZipOutputStream(std::ostream &os)
Initialize a ZipOutputStream object.
Definition
zipoutputstream.cpp:54
zipios::ZipOutputStream::finish
void finish()
Finish up the output by flushing anything left.
Definition
zipoutputstream.cpp:102
zipios::ZipOutputStream::putNextEntry
void putNextEntry(FileEntry::pointer_t entry)
Add an entry to the output stream.
Definition
zipoutputstream.cpp:128
zipios::ZipOutputStream::setComment
void setComment(std::string const &comment)
Set the global comment.
Definition
zipoutputstream.cpp:153
zipios::ZipOutputStream::~ZipOutputStream
virtual ~ZipOutputStream()
Clean up a ZipOutputStream object.
Definition
zipoutputstream.cpp:66
zipios::ZipOutputStream::m_ozf
std::unique_ptr< ZipOutputStreambuf > m_ozf
Definition
zipoutputstream.hpp:54
zipios::ZipOutputStreambuf
Handle the output buffer of a zip archive.
Definition
zipoutputstreambuf.hpp:42
zipios
The zipios namespace includes the Zipios library definitions.
Definition
zipios-config.hpp:50
zipcentraldirectoryentry.hpp
Declaration of the zipios::ZipCentralDirectoryEntry, which represents a directory Zip archive entry.
zipoutputstream.hpp
Define the zipios::ZipOutputStream class.
Generated on Sun Aug 17 2025 05:47:41 for zipios by
1.9.8