4 #include "zipios++/zipios-config.h"
7 #include "zipios++/meta-iostreams.h"
36 updateEntryHeaderInfo() ;
37 setEntryClosedState( ) ;
50 ostream os( _outbuf ) ;
65 if ( ! init( _level ) )
66 cerr <<
"ZipOutputStreambuf::putNextEntry(): init() failed!\n" ;
68 _entries.push_back( entry ) ;
71 ostream os( _outbuf ) ;
74 ent.setLocalHeaderOffset( os.tellp() ) ;
77 os << static_cast< ZipLocalEntry >( ent ) ;
84 _zip_comment = comment ;
95 if( method == STORED )
97 else if ( method == DEFLATED ) {
98 if( _level == NO_COMPRESSION )
101 throw FCollException(
"Specified compression method not supported" ) ;
108 int ZipOutputStreambuf::overflow(
int c ) {
109 return DeflateOutputStreambuf::overflow( c ) ;
118 int ZipOutputStreambuf::sync() {
119 return DeflateOutputStreambuf::sync() ;
127 void ZipOutputStreambuf::setEntryClosedState() {
128 _open_entry = false ;
134 void ZipOutputStreambuf::updateEntryHeaderInfo() {
138 ostream os( _outbuf ) ;
139 int curr_pos = os.tellp() ;
142 ZipCDirEntry &entry = _entries.back() ;
145 entry.setCompressedSize( curr_pos - entry.getLocalHeaderOffset()
146 - entry.getLocalHeaderSize() ) ;
152 now = localtime( <ime );
153 int dosTime = (now->tm_year - 80) << 25 | (now->tm_mon + 1) << 21 | now->tm_mday << 16 |
154 now->tm_hour << 11 | now->tm_min << 5 | now->tm_sec >> 1;
155 entry.setTime(dosTime);
158 os.seekp( entry.getLocalHeaderOffset() ) ;
159 os << static_cast< ZipLocalEntry >( entry ) ;
160 os.seekp( curr_pos ) ;
164 void ZipOutputStreambuf::writeCentralDirectory(
const vector< ZipCDirEntry > &entries,
165 EndOfCentralDirectory eocd,
167 int cdir_start = os.tellp() ;
168 std::vector< ZipCDirEntry >::const_iterator it ;
171 for ( it = entries.begin() ; it != entries.end() ; ++it ) {
173 cdir_size += it->getCDirHeaderSize() ;
175 eocd.setOffset( cdir_start ) ;
176 eocd.setCDirSize( cdir_size ) ;
177 eocd.setTotalCount( entries.size() ) ;