Main Page   Class Hierarchy   Compound List   File List   Compound Members  

appendzip.cpp

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

Generated at Tue Aug 14 20:39:26 2001 for Zipios++ by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000