00001 00002 #include "zipios-config.h" 00003 00004 #include "meta-iostreams.h" 00005 00006 #include "zipinputstreambuf.h" 00007 #include "zipinputstream.h" 00008 00009 using std::istream; 00010 00011 namespace zipios { 00012 00013 ZipInputStream::ZipInputStream( std::istream &is, std::streampos pos ) 00014 : std::istream( 0 ), 00015 // SGIs basic_ifstream calls istream with 0, but calls basic_ios constructor first?? 00016 ifs( 0 ) 00017 { 00018 izf = new ZipInputStreambuf( is.rdbuf(), pos ) ; 00019 // this->rdbuf( izf ) ; is replaced by: 00020 this->init( izf ) ; 00021 } 00022 00023 ZipInputStream::ZipInputStream( const std::string &filename, std::streampos pos ) 00024 : std::istream( 0 ), 00025 ifs( 0 ) 00026 { 00027 ifs = new std::ifstream( filename.c_str(), std::ios::in |std:: ios::binary ) ; 00028 izf = new ZipInputStreambuf( ifs->rdbuf(), pos ) ; 00029 // this->rdbuf( izf ) ; is replaced by: 00030 this->init( izf ) ; 00031 } 00032 00033 int ZipInputStream::available() { 00034 return 1 ; // FIXME: Dummy implementation 00035 } 00036 00037 void ZipInputStream::closeEntry() { 00038 izf->closeEntry() ; 00039 } 00040 00041 void ZipInputStream::close() { 00042 izf->close() ; 00043 } 00044 00045 // ZipLocalEntry *ZipInputStream::createZipCDirEntry( const string 00046 // &name ) {} 00047 00048 ConstEntryPointer ZipInputStream::getNextEntry() { 00049 clear() ; // clear eof and other flags. 00050 return izf->getNextEntry() ; 00051 } 00052 00053 ZipInputStream::~ZipInputStream() { 00054 // It's ok to call delete with a Null pointer. 00055 delete izf ; 00056 delete ifs ; 00057 } 00058 00059 } // namespace 00060 00065 /* 00066 Zipios++ - a small C++ library that provides easy access to .zip files. 00067 Copyright (C) 2000 Thomas Søndergaard 00068 00069 This library is free software; you can redistribute it and/or 00070 modify it under the terms of the GNU Lesser General Public 00071 License as published by the Free Software Foundation; either 00072 version 2 of the License, or (at your option) any later version. 00073 00074 This library is distributed in the hope that it will be useful, 00075 but WITHOUT ANY WARRANTY; without even the implied warranty of 00076 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00077 Lesser General Public License for more details. 00078 00079 You should have received a copy of the GNU Lesser General Public 00080 License along with this library; if not, write to the Free Software 00081 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00082 */