Zipios++
zipfile.h
Go to the documentation of this file.
00001 #ifndef ZIPFILE_H
00002 #define ZIPFILE_H
00003 
00004 #include "zipios++/zipios-config.h"
00005 
00006 #include <vector>
00007 #include "zipios++/meta-iostreams.h"
00008 
00009 #include "zipios++/fcoll.h"
00010 #include "zipios++/ziphead.h"
00011 #include "zipios++/virtualseeker.h"
00012 
00013 namespace zipios {
00014 
00015 using std::ifstream ;
00016 
00020 class ZipFile : public FileCollection {
00021 public:
00033   static ZipFile openEmbeddedZipFile( const string &name ) ;
00034 
00037   ZipFile() {}
00038 
00039   /* Default Copy constructor and copy assignment operator are sufficient. */
00040 
00055   explicit ZipFile( const string &name, int s_off = 0, int e_off = 0
00056                     /* , ios::open_mode mode  = ios::in | ios::binary */ ) ;
00057 
00058   virtual FileCollection *clone() const ;
00059 
00061   virtual ~ZipFile() ;
00062 
00063   virtual void close() ;
00064 
00065   virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
00066   virtual istream *getInputStream( const string &entry_name, 
00067                                      MatchPath matchpath = MATCH ) ;
00068 private:
00069   VirtualSeeker _vs ;
00070   EndOfCentralDirectory  _eocd ;
00071 
00072   bool init( istream &_zipfile ) ;
00073   bool readCentralDirectory( istream &_zipfile ) ;
00074   bool readEndOfCentralDirectory( istream &_zipfile ) ;
00075   bool confirmLocalHeaders( istream &_zipfile ) ;
00076   void setError( string error_str ) ;
00077 };
00078 
00079 
00080 }
00081 
00082 #endif
00083 
00088 /*
00089   Zipios++ - a small C++ library that provides easy access to .zip files.
00090   Copyright (C) 2000  Thomas Søndergaard
00091   
00092   This library is free software; you can redistribute it and/or
00093   modify it under the terms of the GNU Lesser General Public
00094   License as published by the Free Software Foundation; either
00095   version 2 of the License, or (at your option) any later version.
00096   
00097   This library is distributed in the hope that it will be useful,
00098   but WITHOUT ANY WARRANTY; without even the implied warranty of
00099   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00100   Lesser General Public License for more details.
00101   
00102   You should have received a copy of the GNU Lesser General Public
00103   License along with this library; if not, write to the Free Software
00104   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00105 */