Zipios++
appendzip.cpp
Go to the documentation of this file.
00001 #include <cstdlib>
00002 #include "zipios++/zipios-config.h"
00003 
00004 #include "zipios++/meta-iostreams.h"
00005 
00006 #include "zipios++/ziphead.h"
00007 #include "zipios++/zipheadio.h"
00008 
00009 using namespace std ;
00010 using namespace zipios ;
00011 
00012 char *_progname ;
00013 
00014 void printUsage() ;
00015 void exitUsage( int exit_code ) ;
00016 
00017 int main( int argc, char *argv[] ) {
00018   _progname = argv[ 0 ] ;
00019   if ( argc != 3 ) 
00020     exitUsage( 1 ) ;
00021   
00022   ofstream  exef( argv[ 1 ], ios::app | ios::binary ) ;
00023   if( ! exef ) {
00024     cout << "Error: Unable to open " << argv[ 1 ] << " for writing" << endl ;
00025     exitUsage( 1 ) ;
00026   }
00027 
00028   ifstream  zipf( argv[ 2 ], ios::in | ios::binary ) ;
00029   if( ! zipf ) {
00030     cout << "Error: Unable to open " << argv[ 2 ] << " for reading." << endl ;
00031     exitUsage( 1 ) ;
00032   }
00033 
00034   // get eof pos (to become zip file starting position).
00035   uint32 zip_start = exef.tellp() ;
00036   cout << "zip start will be at " << zip_start << endl ;
00037 
00038   // Append zip file to exe file
00039 
00040   exef << zipf.rdbuf() ;
00041   // write zipfile start offset to file
00042   writeUint32( zip_start, exef ) ;
00043 
00044   exef.close() ;
00045   zipf.close() ;
00046   return 0;
00047 }
00048 
00049 
00050 void printUsage() {
00051   cout << "Usage:  " << _progname << " exe-file zipfile" << endl ;
00052 }
00053 
00054 void exitUsage( int exit_code ) {
00055   printUsage() ;
00056   exit( exit_code ) ;
00057 }
00058 
00066 /*
00067   Zipios++ - a small C++ library that provides easy access to .zip files.
00068   Copyright (C) 2000  Thomas Søndergaard
00069   
00070   This library is free software; you can redistribute it and/or
00071   modify it under the terms of the GNU Lesser General Public
00072   License as published by the Free Software Foundation; either
00073   version 2 of the License, or (at your option) any later version.
00074   
00075   This library is distributed in the hope that it will be useful,
00076   but WITHOUT ANY WARRANTY; without even the implied warranty of
00077   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00078   Lesser General Public License for more details.
00079   
00080   You should have received a copy of the GNU Lesser General Public
00081   License along with this library; if not, write to the Free Software
00082   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00083 */