Zipios++
zipfile.h
Go to the documentation of this file.
1 #ifndef ZIPFILE_H
2 #define ZIPFILE_H
3 
4 #include "zipios++/zipios-config.h"
5 
6 #include <vector>
7 #include "zipios++/meta-iostreams.h"
8 
9 #include "zipios++/fcoll.h"
10 #include "zipios++/ziphead.h"
11 #include "zipios++/virtualseeker.h"
12 
13 namespace zipios {
14 
15 using std::ifstream ;
16 
20 class ZipFile : public FileCollection {
21 public:
33  static ZipFile openEmbeddedZipFile( const string &name ) ;
34 
37  ZipFile() {}
38 
39  /* Default Copy constructor and copy assignment operator are sufficient. */
40 
55  explicit ZipFile( const string &name, int s_off = 0, int e_off = 0
56  /* , ios::open_mode mode = ios::in | ios::binary */ ) ;
57 
58  virtual FileCollection *clone() const ;
59 
61  virtual ~ZipFile() ;
62 
63  virtual void close() ;
64 
65  virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
66  virtual istream *getInputStream( const string &entry_name,
67  MatchPath matchpath = MATCH ) ;
68 private:
69  VirtualSeeker _vs ;
70  EndOfCentralDirectory _eocd ;
71 
72  bool init( istream &_zipfile ) ;
73  bool readCentralDirectory( istream &_zipfile ) ;
74  bool readEndOfCentralDirectory( istream &_zipfile ) ;
75  bool confirmLocalHeaders( istream &_zipfile ) ;
76  void setError( string error_str ) ;
77 };
78 
79 
80 }
81 
82 #endif
83 
88 /*
89  Zipios++ - a small C++ library that provides easy access to .zip files.
90  Copyright (C) 2000 Thomas Søndergaard
91 
92  This library is free software; you can redistribute it and/or
93  modify it under the terms of the GNU Lesser General Public
94  License as published by the Free Software Foundation; either
95  version 2 of the License, or (at your option) any later version.
96 
97  This library is distributed in the hope that it will be useful,
98  but WITHOUT ANY WARRANTY; without even the implied warranty of
99  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
100  Lesser General Public License for more details.
101 
102  You should have received a copy of the GNU Lesser General Public
103  License along with this library; if not, write to the Free Software
104  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
105 */
ZipFile()
Default constructor.
Definition: zipfile.h:37
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
Definition: zipfile.cpp:41
Header file that defines FileCollection.
The end of the Central directory structure.
Definition: ziphead.h:159
SimpleSmartPointer is a simple reference counting smart pointer template.
Header file containing classes and functions for reading the central directory and local header field...
VirtualSeeker is a simple class that keeps track of a set of specified &#39;virtual&#39; file endings that ma...
Definition: virtualseeker.h:20
virtual istream * getInputStream(const ConstEntryPointer &entry)
Definition: zipfile.cpp:55
virtual void close()
Closes the FileCollection.
Definition: zipfile.cpp:50
Header file that defines VirtualSeeker.
static ZipFile openEmbeddedZipFile(const string &name)
Definition: zipfile.cpp:19
virtual ~ZipFile()
Destructor.
Definition: zipfile.cpp:46