Listing 1: creapack.c Archive creation utility
/* The package creator written by Janko Stamenovic 1998. */ #include <windows.h> #include <stdio.h> #include <ctype.h> void CopyToPack( char* name, FILE* f ) { FILE* in_f; int c; FILETIME ft[3]; HANDLE h; h = CreateFile( name, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); if ( h == INVALID_HANDLE_VALUE ) { printf( "File %s not found!", name ); return; } GetFileTime( h, &ft[0], &ft[1], &ft[2] ); CloseHandle( h ); fwrite( "JSFHDR", 6, 1, f ); fwrite( ft, sizeof( FILETIME ), 3, f ); fwrite( name, strlen( name ) + 1, 1, f ); in_f = fopen( name, "rb" ); while ( ( c= fgetc( in_f ) ) != EOF ) fputc( c, f ); fclose( in_f ); } void RemoveEndWhite( char* s ) { int L = strlen( s ); while ( L > 0 && isspace( s[ L - 1 ]) ) s[ --L ] = 0; } main() { char currfile[ 256 ]; FILE* inlist, *out_f; inlist = fopen( "filelist", "r" ); if ( !inlist ) { printf( "filelist not found!" ); return 1; } out_f = fopen( "filepack", "wb" ); while ( fgets( currfile, 256, inlist ) != 0 ) { if ( *currfile == 0 ) continue; RemoveEndWhite( currfile ); CopyToPack( currfile, out_f ); } fclose( out_f ); fclose( inlist ); return 0; } /* End of File */