]> git.donarmstrong.com Git - flightcrew.git/blob - src/zipios/src/zipinputstream.cpp
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / zipios / src / zipinputstream.cpp
1
2 #include "zipios++/zipios-config.h"
3
4 #include "zipios++/meta-iostreams.h"
5
6 #include "zipios++/zipinputstreambuf.h"
7 #include "zipios++/zipinputstream.h"
8
9 using std::istream;
10
11 namespace zipios {
12
13 ZipInputStream::ZipInputStream( std::istream &is, std::streampos pos ) 
14   : istream( 0 ), 
15 // SGIs basic_ifstream calls istream with 0, but calls basic_ios constructor first??
16     ifs( 0 )
17 {
18   izf = new ZipInputStreambuf( is.rdbuf(), static_cast< int >( pos ) ) ;
19 //  this->rdbuf( izf ) ; is replaced by:
20   this->init( izf ) ;
21 }
22
23 ZipInputStream::ZipInputStream( const std::string &filename, std::streampos pos )
24   : istream( 0 ),
25     ifs( 0 )
26 {
27   ifs = new std::ifstream( filename.c_str(), std::ios::in |std:: ios::binary ) ;
28   izf = new ZipInputStreambuf( ifs->rdbuf(), static_cast< int >( pos ) ) ;
29 //  this->rdbuf( izf ) ; is replaced by:
30   this->init( izf ) ;
31 }
32
33 int ZipInputStream::available() {
34   return 1 ; // FIXME: Dummy implementation
35 }
36
37 void ZipInputStream::closeEntry() {
38   izf->closeEntry() ;
39 }
40
41 void ZipInputStream::close() {
42   izf->close() ;  
43 }
44
45 //    ZipLocalEntry *ZipInputStream::createZipCDirEntry( const string
46 //    &name ) {}
47
48 ConstEntryPointer ZipInputStream::getNextEntry() {
49   clear() ; // clear eof and other flags.
50   return izf->getNextEntry() ;
51 }
52
53 ZipInputStream::~ZipInputStream() {
54   // It's ok to call delete with a Null pointer.
55   delete izf ;
56   delete ifs ;
57 }
58
59 } // namespace
60
61 /** \file
62     Implementation of ZipInputStream.
63 */
64
65 /*
66   Zipios++ - a small C++ library that provides easy access to .zip files.
67   Copyright (C) 2000  Thomas Søndergaard
68   
69   This library is free software; you can redistribute it and/or
70   modify it under the terms of the GNU Lesser General Public
71   License as published by the Free Software Foundation; either
72   version 2 of the License, or (at your option) any later version.
73   
74   This library is distributed in the hope that it will be useful,
75   but WITHOUT ANY WARRANTY; without even the implied warranty of
76   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
77   Lesser General Public License for more details.
78   
79   You should have received a copy of the GNU Lesser General Public
80   License along with this library; if not, write to the Free Software
81   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
82 */