~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to NuxCore/Zip/zipstream/zipstream.ipp

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-01 19:25:37 UTC
  • Revision ID: neil.patel@canonical.com-20100901192537-mfz7rm6q262pewg6
Import and build NuxCore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
zipstream Library License:
 
3
--------------------------
 
4
 
 
5
The zlib/libpng License Copyright (c) 2003 Jonathan de Halleux.
 
6
 
 
7
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
 
8
 
 
9
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
 
10
 
 
11
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
 
12
 
 
13
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
 
14
 
 
15
3. This notice may not be removed or altered from any source distribution
 
16
 
 
17
Author: Jonathan de Halleux, dehalleux@pelikhan.com, 2003
 
18
*/
 
19
#ifndef ZIPSTREAM_IPP
 
20
#define ZIPSTREAM_IPP
 
21
 
 
22
#include "zipstream.h"
 
23
#include <sstream>
 
24
 
 
25
namespace zlib_stream{
 
26
 
 
27
namespace detail{
 
28
        const int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
 
29
 
 
30
        /* gzip flag byte */
 
31
        const int gz_ascii_flag =  0x01; /* bit 0 set: file probably ascii text */
 
32
        const int gz_head_crc    = 0x02; /* bit 1 set: header CRC present */
 
33
        const int gz_extra_field = 0x04; /* bit 2 set: extra field present */
 
34
        const int gz_orig_name  =  0x08; /* bit 3 set: original file name present */
 
35
        const int gz_comment    =  0x10; /* bit 4 set: file comment present */
 
36
        const int gz_reserved   =  0xE0; /* bits 5..7: reserved */      
 
37
}
 
38
 
 
39
        template<
 
40
                typename Elem, 
 
41
                typename Tr,
 
42
                typename ElemA,
 
43
                typename ByteT,
 
44
                typename ByteAT
 
45
        >
 
46
        basic_zip_streambuf<
 
47
                Elem,Tr,ElemA,ByteT,ByteAT
 
48
                >::basic_zip_streambuf(
 
49
                ostream_reference ostream_,
 
50
                size_t level_,
 
51
                EStrategy strategy_,
 
52
                size_t window_size_,
 
53
                size_t memory_level_,
 
54
                size_t buffer_size_
 
55
        )
 
56
        : 
 
57
                m_ostream(ostream_),
 
58
                m_output_buffer(buffer_size_,0),
 
59
                m_buffer(buffer_size_,0),
 
60
                m_crc(0)
 
61
        {
 
62
                m_zip_stream.zalloc=(alloc_func)0;
 
63
                m_zip_stream.zfree=(free_func)0;
 
64
 
 
65
                m_zip_stream.next_in=NULL;
 
66
                m_zip_stream.avail_in=0;
 
67
                m_zip_stream.avail_out=0;
 
68
                m_zip_stream.next_out=NULL;
 
69
 
 
70
                m_err=deflateInit2(
 
71
                        &m_zip_stream, 
 
72
                        std::min( 9, static_cast<int>(level_)),
 
73
                        Z_DEFLATED,
 
74
                        - static_cast<int>(window_size_), // <-- changed
 
75
                        std::min( 9, static_cast<int>(memory_level_) ),
 
76
                        static_cast<int>(strategy_)
 
77
                        );
 
78
                        
 
79
                setp( &(m_buffer[0]), &(m_buffer[m_buffer.size()-1]));
 
80
        };
 
81
 
 
82
        template<
 
83
                typename Elem, 
 
84
                typename Tr,
 
85
                typename ElemA,
 
86
                typename ByteT,
 
87
                typename ByteAT
 
88
        >
 
89
        basic_zip_streambuf<
 
90
                Elem,Tr,ElemA,ByteT,ByteAT
 
91
                >::~basic_zip_streambuf()
 
92
        {
 
93
                flush();
 
94
                m_ostream.flush();
 
95
                m_err=deflateEnd(&m_zip_stream);
 
96
        };
 
97
 
 
98
        template<
 
99
                typename Elem, 
 
100
                typename Tr,
 
101
                typename ElemA,
 
102
                typename ByteT,
 
103
                typename ByteAT
 
104
        >
 
105
        int basic_zip_streambuf<
 
106
                Elem,Tr,ElemA,ByteT,ByteAT
 
107
                >::sync ()
 
108
        { 
 
109
                if ( pptr() && pptr() > pbase()) 
 
110
                {
 
111
                        int c = overflow( EOF);
 
112
 
 
113
                        if ( c == EOF)
 
114
                                return -1;
 
115
        }
 
116
 
 
117
        return 0;
 
118
        }
 
119
 
 
120
        template<
 
121
                typename Elem, 
 
122
                typename Tr,
 
123
                typename ElemA,
 
124
                typename ByteT,
 
125
                typename ByteAT
 
126
        >
 
127
        typename basic_zip_streambuf<
 
128
                Elem,Tr,ElemA,ByteT,ByteAT
 
129
                >::int_type 
 
130
                basic_zip_streambuf<
 
131
                        Elem,Tr,ElemA,ByteT,ByteAT
 
132
                        >::overflow (
 
133
                        typename basic_zip_streambuf<
 
134
                                Elem,Tr,ElemA,ByteT,ByteAT
 
135
                                >::int_type c
 
136
                        )
 
137
        { 
 
138
        int w = static_cast<int>(pptr() - pbase());
 
139
        if (c != EOF) {
 
140
             *pptr() = c;
 
141
             ++w;
 
142
         }
 
143
         if ( zip_to_stream( pbase(), w)) {
 
144
             setp( pbase(), epptr() - 1);
 
145
             return c;
 
146
         } else
 
147
             return EOF;
 
148
        }
 
149
        
 
150
        template<
 
151
                typename Elem, 
 
152
                typename Tr,
 
153
                typename ElemA,
 
154
                typename ByteT,
 
155
                typename ByteAT
 
156
        >
 
157
        bool basic_zip_streambuf<
 
158
                Elem,Tr,ElemA,ByteT,ByteAT
 
159
                >::zip_to_stream( 
 
160
                typename basic_zip_streambuf<
 
161
                        Elem,Tr,ElemA,ByteT,ByteAT
 
162
                        >::char_type* buffer_, 
 
163
                        std::streamsize buffer_size_
 
164
                )
 
165
        {       
 
166
                std::streamsize written_byte_size=0, total_written_byte_size = 0;
 
167
 
 
168
                m_zip_stream.next_in=(byte_buffer_type)buffer_;
 
169
                m_zip_stream.avail_in=static_cast<uInt>(buffer_size_*sizeof(char_type));
 
170
                m_zip_stream.avail_out=static_cast<uInt>(m_output_buffer.size());
 
171
                m_zip_stream.next_out=&(m_output_buffer[0]);
 
172
                size_t remainder=0;
 
173
 
 
174
                // updating crc
 
175
                m_crc = crc32( 
 
176
                        m_crc, 
 
177
                        m_zip_stream.next_in,
 
178
                        m_zip_stream.avail_in
 
179
                        );              
 
180
 
 
181
                do
 
182
                {
 
183
                        m_err = deflate(&m_zip_stream, 0);
 
184
        
 
185
                        if (m_err == Z_OK  || m_err == Z_STREAM_END)
 
186
                        {
 
187
                                written_byte_size= 
 
188
                                        static_cast<std::streamsize>(m_output_buffer.size()) 
 
189
                                        - m_zip_stream.avail_out;
 
190
                                total_written_byte_size+=written_byte_size;
 
191
                                // ouput buffer is full, dumping to ostream
 
192
                                m_ostream.write( 
 
193
                                        (const char_type*) &(m_output_buffer[0]), 
 
194
                                        static_cast<std::streamsize>( 
 
195
                                                written_byte_size/sizeof(char_type) 
 
196
                                                )
 
197
                                        );
 
198
                                                                                                
 
199
                                // checking if some bytes were not written.
 
200
                                if ( (remainder = written_byte_size%sizeof(char_type))!=0)
 
201
                                {
 
202
                                        // copy to the beginning of the stream
 
203
                                        memcpy(
 
204
                                                &(m_output_buffer[0]), 
 
205
                                                &(m_output_buffer[written_byte_size-remainder]),
 
206
                                                remainder);
 
207
                                        
 
208
                                }
 
209
                                
 
210
                                m_zip_stream.avail_out=
 
211
                                        static_cast<uInt>(m_output_buffer.size()-remainder);
 
212
                                m_zip_stream.next_out=&m_output_buffer[remainder];
 
213
                        }
 
214
                } 
 
215
                while (m_zip_stream.avail_in != 0 && m_err == Z_OK);
 
216
        
 
217
                return m_err == Z_OK;
 
218
        };
 
219
 
 
220
        template<
 
221
                typename Elem, 
 
222
                typename Tr,
 
223
                typename ElemA,
 
224
                typename ByteT,
 
225
                typename ByteAT
 
226
        >
 
227
        std::streamsize basic_zip_streambuf<
 
228
                Elem,Tr,ElemA,ByteT,ByteAT
 
229
                >::flush()
 
230
        {
 
231
                std::streamsize written_byte_size=0, total_written_byte_size=0;
 
232
 
 
233
                size_t remainder=0;
 
234
 
 
235
                // updating crc
 
236
                m_crc = crc32( 
 
237
                        m_crc, 
 
238
                        m_zip_stream.next_in,
 
239
                        m_zip_stream.avail_in
 
240
                        );              
 
241
 
 
242
                do
 
243
                {
 
244
                        m_err = deflate(&m_zip_stream, Z_FINISH);
 
245
                        if (m_err == Z_OK || m_err == Z_STREAM_END)
 
246
                        {
 
247
                                written_byte_size=
 
248
                                        static_cast<std::streamsize>(m_output_buffer.size()) 
 
249
                                        - m_zip_stream.avail_out;
 
250
                                total_written_byte_size+=written_byte_size;
 
251
                                // ouput buffer is full, dumping to ostream
 
252
                                m_ostream.write( 
 
253
                                        (const char_type*) &(m_output_buffer[0]), 
 
254
                                        static_cast<std::streamsize>( 
 
255
                                                written_byte_size/sizeof(char_type)*sizeof(byte_type) 
 
256
                                                )
 
257
                                        );
 
258
                        
 
259
                                // checking if some bytes were not written.
 
260
                                if ( (remainder = written_byte_size%sizeof(char_type))!=0)
 
261
                                {
 
262
                                        // copy to the beginning of the stream
 
263
                                        memcpy(
 
264
                                                &(m_output_buffer[0]), 
 
265
                                                &(m_output_buffer[written_byte_size-remainder]),
 
266
                                                remainder);
 
267
                                        
 
268
                                }
 
269
                                
 
270
                                m_zip_stream.avail_out=static_cast<uInt>(m_output_buffer.size()-remainder);
 
271
                                m_zip_stream.next_out=&m_output_buffer[remainder];
 
272
                        }
 
273
                } while (m_err == Z_OK);
 
274
 
 
275
                m_ostream.flush();
 
276
 
 
277
                return total_written_byte_size;
 
278
        };
 
279
 
 
280
 
 
281
        template<
 
282
                typename Elem, 
 
283
                typename Tr,
 
284
                typename ElemA,
 
285
                typename ByteT,
 
286
                typename ByteAT
 
287
        >
 
288
    basic_unzip_streambuf<
 
289
                Elem,Tr,ElemA,ByteT,ByteAT
 
290
                >::basic_unzip_streambuf(
 
291
                        istream_reference istream_,
 
292
                        size_t window_size_,
 
293
                        size_t read_buffer_size_,
 
294
                        size_t input_buffer_size_
 
295
        )
 
296
        :  
 
297
                m_istream(istream_),
 
298
                m_input_buffer(input_buffer_size_),
 
299
                m_buffer(read_buffer_size_),
 
300
                m_crc(0)
 
301
        {
 
302
                // setting zalloc, zfree and opaque
 
303
                m_zip_stream.zalloc=(alloc_func)0;
 
304
                m_zip_stream.zfree=(free_func)0;
 
305
 
 
306
                m_zip_stream.next_in=NULL;
 
307
                m_zip_stream.avail_in=0;
 
308
                m_zip_stream.avail_out=0;
 
309
                m_zip_stream.next_out=NULL;
 
310
        
 
311
                m_err=inflateInit2(
 
312
                        &m_zip_stream,
 
313
                        -static_cast<int>(window_size_)
 
314
                );
 
315
                
 
316
                setg( &(m_buffer[0])+4,     // beginning of putback area
 
317
                    &(m_buffer[0])+4,     // read position
 
318
                &(m_buffer[0])+4);    // end position    
 
319
        };
 
320
 
 
321
        template<
 
322
                typename Elem, 
 
323
                typename Tr,
 
324
                typename ElemA,
 
325
                typename ByteT,
 
326
                typename ByteAT
 
327
        >
 
328
    size_t basic_unzip_streambuf<
 
329
                Elem,Tr,ElemA,ByteT,ByteAT
 
330
                >::fill_input_buffer()
 
331
        {
 
332
                m_zip_stream.next_in=&(m_input_buffer[0]);
 
333
                m_istream.read( 
 
334
                        (char_type*)(&(m_input_buffer[0])), 
 
335
                        static_cast<std::streamsize>(m_input_buffer.size()/sizeof(char_type)) 
 
336
                        ); 
 
337
                return m_zip_stream.avail_in=m_istream.gcount()*sizeof(char_type);
 
338
        }
 
339
 
 
340
 
 
341
        template<
 
342
                typename Elem, 
 
343
                typename Tr,
 
344
                typename ElemA,
 
345
                typename ByteT,
 
346
                typename ByteAT
 
347
        >
 
348
    basic_unzip_streambuf<
 
349
                Elem,Tr,ElemA,ByteT,ByteAT
 
350
                >::~basic_unzip_streambuf()
 
351
        {
 
352
                inflateEnd(&m_zip_stream);
 
353
        };
 
354
 
 
355
        template<
 
356
                typename Elem, 
 
357
                typename Tr,
 
358
                typename ElemA,
 
359
                typename ByteT,
 
360
                typename ByteAT
 
361
        >
 
362
    typename basic_unzip_streambuf<
 
363
                Elem,Tr,ElemA,ByteT,ByteAT
 
364
                >::int_type 
 
365
                basic_unzip_streambuf<
 
366
                        Elem,Tr,ElemA,ByteT,ByteAT
 
367
                        >::underflow() 
 
368
        { 
 
369
                if ( gptr() && ( gptr() < egptr()))
 
370
                        return * reinterpret_cast<unsigned char *>( gptr());
 
371
     
 
372
       int n_putback = static_cast<int>(gptr() - eback());
 
373
       if ( n_putback > 4)
 
374
          n_putback = 4;
 
375
       memcpy( 
 
376
                        &(m_buffer[0]) + (4 - n_putback), 
 
377
                        gptr() - n_putback, 
 
378
                        n_putback*sizeof(char_type)
 
379
                        );
 
380
  
 
381
           int num = unzip_from_stream( 
 
382
                   &(m_buffer[0])+4, 
 
383
                   static_cast<std::streamsize>((m_buffer.size()-4)*sizeof(char_type))
 
384
                   );
 
385
        if (num <= 0) // ERROR or EOF
 
386
           return EOF;
 
387
    
 
388
        // reset buffer pointers
 
389
        setg( &(m_buffer[0]) + (4 - n_putback),   // beginning of putback area
 
390
              &(m_buffer[0]) + 4,                 // read position
 
391
              &(m_buffer[0]) + 4 + num);          // end of buffer
 
392
    
 
393
         // return next character
 
394
         return* reinterpret_cast<unsigned char *>( gptr());    
 
395
     }
 
396
 
 
397
        template<
 
398
                typename Elem, 
 
399
                typename Tr,
 
400
                typename ElemA,
 
401
                typename ByteT,
 
402
                typename ByteAT
 
403
        >
 
404
    std::streamsize basic_unzip_streambuf<
 
405
                Elem,Tr,ElemA,ByteT,ByteAT
 
406
                >::unzip_from_stream( 
 
407
                        char_type* buffer_, 
 
408
                        std::streamsize buffer_size_
 
409
                        )
 
410
        {
 
411
                m_zip_stream.next_out=(byte_buffer_type)buffer_;
 
412
                m_zip_stream.avail_out=static_cast<uInt>(buffer_size_*sizeof(char_type));
 
413
                size_t count =m_zip_stream.avail_in;
 
414
 
 
415
                do
 
416
                {
 
417
                        if (m_zip_stream.avail_in==0)
 
418
                                count=fill_input_buffer();
 
419
 
 
420
                        if (m_zip_stream.avail_in)
 
421
                        {
 
422
                                m_err = inflate( &m_zip_stream,  Z_SYNC_FLUSH );
 
423
                        }
 
424
                } while (m_err==Z_OK && m_zip_stream.avail_out != 0 && count != 0);
 
425
 
 
426
                // updating crc
 
427
                m_crc = crc32( 
 
428
                        m_crc, 
 
429
                        (byte_buffer_type)buffer_,
 
430
                        buffer_size_ - m_zip_stream.avail_out/sizeof(char_type)
 
431
                        );      
 
432
                std::streamsize n_read = buffer_size_ - m_zip_stream.avail_out/sizeof(char_type);
 
433
                
 
434
                // check if it is the end
 
435
                if (m_err==Z_STREAM_END)
 
436
                        put_back_from_zip_stream();                             
 
437
                
 
438
                return n_read;
 
439
        }
 
440
        
 
441
        template<
 
442
                typename Elem, 
 
443
                typename Tr,
 
444
                typename ElemA,
 
445
                typename ByteT,
 
446
                typename ByteAT
 
447
        >
 
448
        void basic_unzip_streambuf<
 
449
                Elem,Tr,ElemA,ByteT,ByteAT
 
450
                >::put_back_from_zip_stream()
 
451
        {
 
452
                if (m_zip_stream.avail_in==0)
 
453
                        return;
 
454
 
 
455
                m_istream.clear( ios::goodbit );
 
456
                m_istream.seekg(
 
457
                        -static_cast<int>(m_zip_stream.avail_in),
 
458
                        ios_base::cur
 
459
                        );
 
460
 
 
461
                m_zip_stream.avail_in=0;
 
462
        };
 
463
 
 
464
        template<
 
465
                typename Elem, 
 
466
                typename Tr,
 
467
                typename ElemA,
 
468
                typename ByteT,
 
469
                typename ByteAT
 
470
        >
 
471
        int basic_zip_istream<
 
472
                Elem,Tr,ElemA,ByteT,ByteAT
 
473
                >::check_header()
 
474
        {
 
475
            int method; /* method byte */
 
476
            int flags;  /* flags byte */
 
477
            uInt len;
 
478
                int c;
 
479
                int err=0;
 
480
                z_stream& zip_stream = rdbuf()->get_zip_stream();
 
481
 
 
482
            /* Check the gzip magic header */
 
483
                 for (len = 0; len < 2; len++) 
 
484
                 {
 
485
                        c = (int)rdbuf()->get_istream().get();
 
486
                        if (c != detail::gz_magic[len]) 
 
487
                        {
 
488
                            if (len != 0) 
 
489
                                        rdbuf()->get_istream().unget();
 
490
                            if (c!= EOF) 
 
491
                            {
 
492
                                        rdbuf()->get_istream().unget();
 
493
                            }
 
494
                    
 
495
                            err = zip_stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
 
496
                            m_is_gzip = false;
 
497
                            return err;
 
498
                        }
 
499
                }
 
500
    
 
501
                m_is_gzip = true;
 
502
                method = (int)rdbuf()->get_istream().get();
 
503
                flags = (int)rdbuf()->get_istream().get();
 
504
                if (method != Z_DEFLATED || (flags & detail::gz_reserved) != 0) 
 
505
                {
 
506
                        err = Z_DATA_ERROR;
 
507
                        return err;
 
508
                }
 
509
 
 
510
            /* Discard time, xflags and OS code: */
 
511
            for (len = 0; len < 6; len++) 
 
512
                        rdbuf()->get_istream().get();
 
513
        
 
514
            if ((flags & detail::gz_extra_field) != 0) 
 
515
            { 
 
516
                        /* skip the extra field */
 
517
                        len  =  (uInt)rdbuf()->get_istream().get();
 
518
                        len += ((uInt)rdbuf()->get_istream().get())<<8;
 
519
                        /* len is garbage if EOF but the loop below will quit anyway */
 
520
                        while (len-- != 0 && rdbuf()->get_istream().get() != EOF) ;
 
521
            }
 
522
            if ((flags & detail::gz_orig_name) != 0) 
 
523
            { 
 
524
                        /* skip the original file name */
 
525
                        while ((c = rdbuf()->get_istream().get()) != 0 && c != EOF) ;
 
526
                }
 
527
            if ((flags & detail::gz_comment) != 0) 
 
528
            {   
 
529
                        /* skip the .gz file comment */
 
530
                        while ((c = rdbuf()->get_istream().get()) != 0 && c != EOF) ;
 
531
                }
 
532
                if ((flags & detail::gz_head_crc) != 0) 
 
533
                {  /* skip the header crc */
 
534
                        for (len = 0; len < 2; len++) 
 
535
                                rdbuf()->get_istream().get();
 
536
                }
 
537
                err = rdbuf()->get_istream().eof() ? Z_DATA_ERROR : Z_OK;
 
538
 
 
539
                return err;
 
540
        }
 
541
 
 
542
        template<
 
543
                typename Elem, 
 
544
                typename Tr,
 
545
                typename ElemA,
 
546
                typename ByteT,
 
547
                typename ByteAT
 
548
        >
 
549
        void basic_zip_istream<
 
550
                Elem,Tr,ElemA,ByteT,ByteAT
 
551
                >::read_footer()
 
552
        {               
 
553
                if (m_is_gzip)
 
554
                {
 
555
                        read_long( rdbuf()->get_istream(), m_gzip_crc );
 
556
                        read_long( rdbuf()->get_istream(), m_gzip_data_size );
 
557
                }
 
558
        }
 
559
 
 
560
        template<
 
561
                typename Elem, 
 
562
                typename Tr,
 
563
                typename ElemA,
 
564
                typename ByteT,
 
565
                typename ByteAT
 
566
        >
 
567
    void basic_zip_ostream<
 
568
                Elem,Tr,ElemA,ByteT,ByteAT
 
569
                >::put_long( 
 
570
                        typename basic_zip_ostream<
 
571
                                Elem,Tr,ElemA,ByteT,ByteAT
 
572
                                >::ostream_reference out_, 
 
573
                        unsigned long x_
 
574
                        )
 
575
    {
 
576
                static const int size_ul = sizeof(unsigned long);
 
577
                static const int size_c = sizeof(char_type);
 
578
        static const int n_end = size_ul/size_c;
 
579
                out_.write(reinterpret_cast<char_type const*>(&x_), n_end);
 
580
    }
 
581
   
 
582
        template<
 
583
                typename Elem, 
 
584
                typename Tr,
 
585
                typename ElemA,
 
586
                typename ByteT,
 
587
                typename ByteAT
 
588
        >
 
589
    void basic_zip_istream<
 
590
                        Elem,Tr,ElemA,ByteT,ByteAT
 
591
                        >::read_long(
 
592
                                istream_reference in_, 
 
593
                        unsigned long& x_
 
594
                        )
 
595
        {
 
596
                static const int size_ul = sizeof(unsigned long);
 
597
                static const int size_c = sizeof(char_type);
 
598
        static const int n_end = size_ul/size_c;
 
599
                in_.read(reinterpret_cast<char*>(&x_),n_end);
 
600
        }
 
601
    
 
602
        template<
 
603
                typename Elem, 
 
604
                typename Tr,
 
605
                typename ElemA,
 
606
                typename ByteT,
 
607
                typename ByteAT
 
608
        >
 
609
        void basic_zip_ostream<
 
610
                Elem,Tr,ElemA,ByteT,ByteAT
 
611
                >::add_header()
 
612
        {
 
613
            char_type zero=0;
 
614
            
 
615
        rdbuf()->get_ostream()
 
616
                        .put(static_cast<char_type>(detail::gz_magic[0]))
 
617
                        .put(static_cast<char_type>(detail::gz_magic[1]))
 
618
                        .put(static_cast<char_type>(Z_DEFLATED))
 
619
                        .put(zero) //flags
 
620
                        .put(zero).put(zero).put(zero).put(zero) // time
 
621
                        .put(zero) //xflags
 
622
                        .put(static_cast<char_type>(OS_CODE));
 
623
        }
 
624
 
 
625
        template<
 
626
                typename Elem, 
 
627
                typename Tr,
 
628
                typename ElemA,
 
629
                typename ByteT,
 
630
                typename ByteAT
 
631
        >
 
632
        void basic_zip_ostream<
 
633
                Elem,Tr,ElemA,ByteT,ByteAT
 
634
                >::add_footer()
 
635
        {
 
636
                put_long( rdbuf()->get_ostream(), rdbuf()->get_crc() );
 
637
                put_long( rdbuf()->get_ostream(), rdbuf()->get_in_size() ); 
 
638
        };
 
639
 
 
640
}; // zlib_sream
 
641
 
 
642
#endif
 
 
b'\\ No newline at end of file'