Zipios++
src
zipoutputstream.cpp
Go to the documentation of this file.
1
2
#include "zipios++/zipios-config.h"
3
4
#include "zipios++/meta-iostreams.h"
5
6
#include "
zipios++/zipoutputstreambuf.h
"
7
#include "
zipios++/zipoutputstream.h
"
8
9
using
std::ostream;
10
11
namespace
zipios {
12
13
ZipOutputStream::ZipOutputStream
( std::ostream &os )
14
: ostream( 0 ),
15
// SGIs basic_ifstream calls istream with 0, but calls basic_ios constructor first??
16
ofs( 0 )
17
{
18
ozf =
new
ZipOutputStreambuf
( os.rdbuf() ) ;
19
20
init( ozf ) ;
21
}
22
23
24
ZipOutputStream::ZipOutputStream
(
const
std::string &filename )
25
: ostream( 0 ),
26
ofs( 0 )
27
{
28
ofs =
new
std::ofstream( filename.c_str(), std::ios::out | std::ios::binary ) ;
29
ozf =
new
ZipOutputStreambuf
( ofs->rdbuf() ) ;
30
this->init( ozf ) ;
31
}
32
33
void
ZipOutputStream::closeEntry
() {
34
ozf->
closeEntry
() ;
35
}
36
37
38
void
ZipOutputStream::close
() {
39
ozf->
close
() ;
40
if
( ofs )
41
ofs->close() ;
42
}
43
44
45
void
ZipOutputStream::finish
() {
46
ozf->
finish
() ;
47
}
48
49
50
void
ZipOutputStream::putNextEntry
(
const
ZipCDirEntry
&entry ) {
51
ozf->
putNextEntry
( entry ) ;
52
}
53
54
void
ZipOutputStream::putNextEntry
(
const
std::string& entryName) {
55
putNextEntry
(
ZipCDirEntry
(entryName));
56
}
57
58
59
void
ZipOutputStream::setComment
(
const
std::string &comment ) {
60
ozf->
setComment
( comment ) ;
61
}
62
63
64
void
ZipOutputStream::setLevel
(
int
level ) {
65
ozf->
setLevel
( level ) ;
66
}
67
68
69
void
ZipOutputStream::setMethod
(
StorageMethod
method ) {
70
ozf->
setMethod
( method ) ;
71
}
72
73
74
ZipOutputStream::~ZipOutputStream
() {
75
// It's ok to call delete with a Null pointer.
76
delete
ozf ;
77
delete
ofs ;
78
}
79
80
}
// namespace
81
86
/*
87
Zipios++ - a small C++ library that provides easy access to .zip files.
88
Copyright (C) 2000 Thomas Søndergaard
89
90
This library is free software; you can redistribute it and/or
91
modify it under the terms of the GNU Lesser General Public
92
License as published by the Free Software Foundation; either
93
version 2 of the License, or (at your option) any later version.
94
95
This library is distributed in the hope that it will be useful,
96
but WITHOUT ANY WARRANTY; without even the implied warranty of
97
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
98
Lesser General Public License for more details.
99
100
You should have received a copy of the GNU Lesser General Public
101
License along with this library; if not, write to the Free Software
102
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
103
*/
zipios::ZipOutputStream::setComment
void setComment(const std::string &comment)
Sets the global comment for the Zip archive.
Definition:
zipoutputstream.cpp:59
zipios::StorageMethod
StorageMethod
The types used with FileEntry::setMethod and FileEntry::getMethod.
Definition:
fileentry.h:25
zipios::ZipOutputStream::putNextEntry
void putNextEntry(const ZipCDirEntry &entry)
Definition:
zipoutputstream.cpp:50
zipios::ZipOutputStream::setLevel
void setLevel(int level)
Sets the compression level to be used for subsequent entries.
Definition:
zipoutputstream.cpp:64
zipios::ZipOutputStreambuf::finish
void finish()
Closes the current entry (if one is open), then writes the Zip Central Directory Structure closing th...
Definition:
zipoutputstreambuf.cpp:46
zipios::ZipOutputStreambuf::setMethod
void setMethod(StorageMethod method)
Sets the compression method to be used.
Definition:
zipoutputstreambuf.cpp:93
zipios::ZipOutputStream::closeEntry
void closeEntry()
Closes the current entry updates its header with the relevant size information and positions the stre...
Definition:
zipoutputstream.cpp:33
zipoutputstream.h
zipios::ZipOutputStream::close
void close()
Calls finish and if the ZipOutputStream was created with a filename as a parameter that file is close...
Definition:
zipoutputstream.cpp:38
zipios::ZipOutputStreambuf::putNextEntry
void putNextEntry(const ZipCDirEntry &entry)
Begins writing the next entry.
Definition:
zipoutputstreambuf.cpp:61
zipios::ZipCDirEntry
Specialization of ZipLocalEntry, that add fields for storing the extra information,...
Definition:
ziphead.h:102
zipios::ZipOutputStream::finish
void finish()
Closes the current entry (if one is open), then writes the Zip Central Directory Structure closing th...
Definition:
zipoutputstream.cpp:45
zipios::ZipOutputStream::ZipOutputStream
ZipOutputStream(std::ostream &os)
ZipOutputStream constructor.
Definition:
zipoutputstream.cpp:13
zipios::ZipOutputStreambuf
ZipOutputStreambuf is a zip output streambuf filter.
Definition:
zipoutputstreambuf.h:17
zipios::ZipOutputStream::setMethod
void setMethod(StorageMethod method)
Sets the compression method to be used.
Definition:
zipoutputstream.cpp:69
zipios::ZipOutputStreambuf::close
void close()
Calls finish.
Definition:
zipoutputstreambuf.cpp:41
zipoutputstreambuf.h
zipios::ZipOutputStreambuf::setComment
void setComment(const string &comment)
Sets the global comment for the Zip archive.
Definition:
zipoutputstreambuf.cpp:83
zipios::ZipOutputStreambuf::setLevel
void setLevel(int level)
Sets the compression level to be used for subsequent entries.
Definition:
zipoutputstreambuf.cpp:88
zipios::ZipOutputStream::~ZipOutputStream
virtual ~ZipOutputStream()
Destructor.
Definition:
zipoutputstream.cpp:74
zipios::ZipOutputStreambuf::closeEntry
void closeEntry()
Closes the current entry, and positions the stream read pointer at the beginning of the next entry (i...
Definition:
zipoutputstreambuf.cpp:30
Generated by
1.8.17