zipios  2.2.0
Zipios – a small C++ library that provides 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-2019 Made to Order Software Corporation
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 
35 namespace zipios
36 {
37 
55  //: std::ostream()
56  : m_ozf(new ZipOutputStreambuf(os.rdbuf()))
57 {
58  init(m_ozf.get());
59 }
60 
61 
68 {
69 }
70 
71 
77 {
78  m_ozf->closeEntry();
79 }
80 
81 
91 {
92  m_ozf->close();
93 }
94 
95 
104 {
105  m_ozf->finish();
106 }
107 
108 
130 {
131  // if we do not yet have a ZipCentralDirectoryEntry object, create
132  // one from the input entry (the input entry is actually expected
133  // to be a DirectoryEntry!)
134  ZipCentralDirectoryEntry * central_directory_entry(dynamic_cast<ZipCentralDirectoryEntry *>(entry.get()));
135  if(central_directory_entry == nullptr)
136  {
137  entry.reset(new ZipCentralDirectoryEntry(*entry));
138  }
139 
140  m_ozf->putNextEntry(entry);
141 }
142 
143 
154 void ZipOutputStream::setComment(std::string const & comment)
155 {
156  m_ozf->setComment(comment);
157 }
158 
159 
160 } // zipios namespace
161 
162 // Local Variables:
163 // mode: cpp
164 // indent-tabs-mode: nil
165 // c-basic-offset: 4
166 // tab-width: 4
167 // End:
168 
169 // vim: ts=4 sw=4 et
The zipios namespace includes the Zipios library definitions.
Definition: backbuffer.cpp:35
ZipOutputStream(std::ostream &os)
Initialize a ZipOutputStream object.
void setComment(std::string const &comment)
Set the global comment.
std::unique_ptr< ZipOutputStreambuf > m_ozf
Define the zipios::ZipOutputStream class.
void close()
Close the current stream.
void putNextEntry(FileEntry::pointer_t entry)
Add an entry to the output stream.
virtual ~ZipOutputStream()
Clean up a ZipOutputStream object.
A specialization of ZipLocalEntry for.
Declaration of the zipios::ZipCentralDirectoryEntry, which represents a directory Zip archive entry...
Handle the output buffer of a zip archive.
std::shared_ptr< FileEntry > pointer_t
Definition: fileentry.hpp:78
void finish()
Finish up the output by flushing anything left.