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