Zipios++
zipinputstream.cpp
Go to the documentation of this file.
1 
2 #include "zipios++/zipios-config.h"
3 
4 #include "zipios++/meta-iostreams.h"
5 
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(), 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(), 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 
38  izf->closeEntry() ;
39 }
40 
42  izf->close() ;
43 }
44 
45 // ZipLocalEntry *ZipInputStream::createZipCDirEntry( const string
46 // &name ) {}
47 
49  clear() ; // clear eof and other flags.
50  return izf->getNextEntry() ;
51 }
52 
54  // It's ok to call delete with a Null pointer.
55  delete izf ;
56  delete ifs ;
57 }
58 
59 } // namespace
60 
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 */