zipios
2.3.4
Zipios -- a small C++ library providing easy access to .zip files.
src
gzipoutputstream.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
30
#include "
gzipoutputstream.hpp
"
31
32
#include <fstream>
33
34
35
namespace
zipios
36
{
37
63
GZIPOutputStream::GZIPOutputStream
(std::ostream & os,
FileEntry::CompressionLevel
compression_level)
64
: m_ozf(std::make_unique<
GZIPOutputStreambuf
>(os.rdbuf(), compression_level))
65
{
66
init(
m_ozf
.get());
67
}
68
69
80
GZIPOutputStream::GZIPOutputStream
(std::string
const
& filename,
FileEntry::CompressionLevel
compression_level)
81
: std::ostream(0)
82
, m_ofs(std::make_unique<std::ofstream>(filename.c_str(), std::ios::out | std::ios::binary))
83
, m_ozf(std::make_unique<
GZIPOutputStreambuf
>(m_ofs->rdbuf(), compression_level))
84
{
85
init(
m_ozf
.get());
86
}
87
88
93
GZIPOutputStream::~GZIPOutputStream
()
94
{
95
}
96
97
107
void
GZIPOutputStream::setFilename
(std::string
const
& filename)
108
{
109
m_ozf
->setFilename(filename);
110
}
111
112
121
void
GZIPOutputStream::setComment
(std::string
const
& comment)
122
{
123
m_ozf
->setComment(comment);
124
}
125
126
135
void
GZIPOutputStream::close
()
136
{
137
m_ozf
->close();
138
if
(
m_ofs
)
139
{
140
m_ofs
->close();
141
}
142
}
143
144
148
void
GZIPOutputStream::finish
()
149
{
150
m_ozf
->finish();
151
}
152
153
154
}
// zipios namespace
155
156
// Local Variables:
157
// mode: cpp
158
// indent-tabs-mode: nil
159
// c-basic-offset: 4
160
// tab-width: 4
161
// End:
162
163
// vim: ts=4 sw=4 et
zipios::FileEntry::CompressionLevel
int CompressionLevel
The compression level to be used to save an entry.
Definition
fileentry.hpp:85
zipios::GZIPOutputStream::m_ofs
std::unique_ptr< std::ofstream > m_ofs
Definition
gzipoutputstream.hpp:55
zipios::GZIPOutputStream::setFilename
void setFilename(std::string const &filename)
Set the filename of a stream.
Definition
gzipoutputstream.cpp:107
zipios::GZIPOutputStream::m_ozf
std::unique_ptr< GZIPOutputStreambuf > m_ozf
Definition
gzipoutputstream.hpp:56
zipios::GZIPOutputStream::setComment
void setComment(std::string const &comment)
Set a comment in the stream.
Definition
gzipoutputstream.cpp:121
zipios::GZIPOutputStream::close
void close()
Close the streams.
Definition
gzipoutputstream.cpp:135
zipios::GZIPOutputStream::~GZIPOutputStream
virtual ~GZIPOutputStream()
Destroy the output stream.
Definition
gzipoutputstream.cpp:93
zipios::GZIPOutputStream::GZIPOutputStream
GZIPOutputStream(std::ostream &os, FileEntry::CompressionLevel compression_level)
Create a ZIP output stream object.
Definition
gzipoutputstream.cpp:63
zipios::GZIPOutputStream::finish
void finish()
Finishes the stream.
Definition
gzipoutputstream.cpp:148
zipios::GZIPOutputStreambuf
Save the output stream buffer.
Definition
gzipoutputstreambuf.hpp:42
gzipoutputstream.hpp
This file defines zipios::GZIPOutputStream.
zipios
The zipios namespace includes the Zipios library definitions.
Definition
zipios-config.hpp:50
Generated on Tue Sep 9 2025 05:00:53 for zipios by
1.9.8