Zipios++
appendzip.cpp
Go to the documentation of this file.
1 #include "zipios++/zipios-config.h"
2 
3 #include "zipios++/meta-iostreams.h"
4 
5 #include "zipios++/ziphead.h"
6 #include "zipios++/zipheadio.h"
7 
8 #include <cstdlib>
9 
10 using namespace std ;
11 using namespace zipios ;
12 
13 char *_progname ;
14 
15 void printUsage() ;
16 void exitUsage( int exit_code ) ;
17 
18 int main( int argc, char *argv[] ) {
19  _progname = argv[ 0 ] ;
20  if ( argc != 3 )
21  exitUsage( 1 ) ;
22 
23  ofstream exef( argv[ 1 ], ios::app | ios::binary ) ;
24  if( ! exef ) {
25  cout << "Error: Unable to open " << argv[ 1 ] << " for writing" << endl ;
26  exitUsage( 1 ) ;
27  }
28 
29  ifstream zipf( argv[ 2 ], ios::in | ios::binary ) ;
30  if( ! zipf ) {
31  cout << "Error: Unable to open " << argv[ 2 ] << " for reading." << endl ;
32  exitUsage( 1 ) ;
33  }
34 
35  // get eof pos (to become zip file starting position).
36  uint32 zip_start = exef.tellp() ;
37  cout << "zip start will be at " << zip_start << endl ;
38 
39  // Append zip file to exe file
40 
41  exef << zipf.rdbuf() ;
42  // write zipfile start offset to file
43  writeUint32( zip_start, exef ) ;
44 
45  exef.close() ;
46  zipf.close() ;
47  return 0;
48 }
49 
50 
51 void printUsage() {
52  cout << "Usage: " << _progname << " exe-file zipfile" << endl ;
53 }
54 
55 void exitUsage( int exit_code ) {
56  printUsage() ;
57  exit( exit_code ) ;
58 }
59 
67 /*
68  Zipios++ - a small C++ library that provides easy access to .zip files.
69  Copyright (C) 2000 Thomas Søndergaard
70 
71  This library is free software; you can redistribute it and/or
72  modify it under the terms of the GNU Lesser General Public
73  License as published by the Free Software Foundation; either
74  version 2 of the License, or (at your option) any later version.
75 
76  This library is distributed in the hope that it will be useful,
77  but WITHOUT ANY WARRANTY; without even the implied warranty of
78  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79  Lesser General Public License for more details.
80 
81  You should have received a copy of the GNU Lesser General Public
82  License along with this library; if not, write to the Free Software
83  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
84 */
Header file containing classes and functions for reading the central directory and local header field...
Header file that defines I/O functions for the header structures defined in ziphead.h.