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