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"
12
13namespace zipios {
14
15using std::ifstream ;
16
20class ZipFile : public FileCollection {
21public:
33 static ZipFile openEmbeddedZipFile( const string &name ) ;
34
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 ) ;
68private:
69 VirtualSeeker _vs ;
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*/
The end of the Central directory structure.
Definition ziphead.h:159
FileCollection is an abstract baseclass that represents a collection of files.
Definition fcoll.h:21
SimpleSmartPointer is a simple reference counting smart pointer template.
VirtualSeeker is a simple class that keeps track of a set of specified 'virtual' file endings that ma...
ZipFile is a FileCollection, where the files are stored in a .zip file.
Definition zipfile.h:20
virtual ~ZipFile()
Destructor.
Definition zipfile.cpp:46
virtual void close()
Closes the FileCollection.
Definition zipfile.cpp:50
ZipFile()
Default constructor.
Definition zipfile.h:37
static ZipFile openEmbeddedZipFile(const string &name)
Opens a Zip archive embedded in another file, by writing the zip archive to the end of the file follo...
Definition zipfile.cpp:19
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
Definition zipfile.cpp:41
virtual istream * getInputStream(const ConstEntryPointer &entry)
Returns a pointer to an opened istream for the specified FileEntry.
Definition zipfile.cpp:55
Header file that defines FileCollection.
Header file that defines VirtualSeeker.
Header file containing classes and functions for reading the central directory and local header field...