4 #include "zipios++/zipios-config.h"
7 #include "zipios++/meta-iostreams.h"
9 #include "zipios++/fcoll.h"
10 #include "zipios++/ziphead.h"
11 #include "zipios++/virtualseeker.h"
12 #include "../../FlightCrew/Misc/BoostFilesystemUse.h"
18 /** \anchor zipfile_anchor
19 ZipFile is a FileCollection, where the files are stored
21 class ZipFile : public FileCollection {
23 /** \anchor zipfile_openembeddedzipfile
24 Opens a Zip archive embedded in another file, by writing the zip
25 archive to the end of the file followed by the start offset of
26 the zip file. The offset must be written in zip-file byte-order
27 (little endian). The program appendzip, which is part of the
28 Zipios++ distribution can be used to append a Zip archive to a
29 file, e.g. a binary program.
30 @throw FColException Thrown if the specified file name is not a valid zip
32 @throw IOException Thrown if an I/O problem is encountered, while the directory
33 of the specified zip archive is being read. */
34 static ZipFile openEmbeddedZipFile( const string &name ) ;
36 /** Default constructor.
40 /* Default Copy constructor and copy assignment operator are sufficient. */
42 /** Constructor. Opens the zip file name. If the zip "file" is
43 embedded in a file that contains other data, e.g. a binary
44 program, the offset of the zip file start and end must be
46 @param name The filename of the zip file to open.
47 @param s_off Offset relative to the start of the file, that
48 indicates the beginning of the zip file.
49 @param e_off Offset relative to the end of the file, that
50 indicates the end of the zip file. The offset is a positive number,
51 even though the offset is towards the beginning of the file.
52 @throw FColException Thrown if the specified file name is not a valid zip
54 @throw IOException Thrown if an I/O problem is encountered, while the directory
55 of the specified zip archive is being read. */
56 explicit ZipFile( const string &name, int s_off = 0, int e_off = 0
57 /* , ios::open_mode mode = ios::in | ios::binary */ ) ;
59 explicit ZipFile( const fs::path &name, int s_off = 0, int e_off = 0
60 /* , ios::open_mode mode = ios::in | ios::binary */ ) ;
62 virtual FileCollection *clone() const ;
67 virtual void close() ;
69 virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
70 virtual istream *getInputStream( const string &entry_name,
71 MatchPath matchpath = MATCH ) ;
74 EndOfCentralDirectory _eocd ;
76 bool init( istream &_zipfile ) ;
77 bool readCentralDirectory( istream &_zipfile ) ;
78 bool readEndOfCentralDirectory( istream &_zipfile ) ;
79 bool confirmLocalHeaders( istream &_zipfile ) ;
80 void setError( string error_str ) ;
89 Header file that defines ZipFile.
93 Zipios++ - a small C++ library that provides easy access to .zip files.
94 Copyright (C) 2000 Thomas Søndergaard
96 This library is free software; you can redistribute it and/or
97 modify it under the terms of the GNU Lesser General Public
98 License as published by the Free Software Foundation; either
99 version 2 of the License, or (at your option) any later version.
101 This library is distributed in the hope that it will be useful,
102 but WITHOUT ANY WARRANTY; without even the implied warranty of
103 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
104 Lesser General Public License for more details.
106 You should have received a copy of the GNU Lesser General Public
107 License along with this library; if not, write to the Free Software
108 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA