/* http://www.mrwadlo.com */ #include #include void showpercent(int percent); void createfilename(); int mark; char input1file[15]; char input2file[15]; char outputfile[15]; int main() { long i; long file1size; long file2size; long file3size; char sym; int percent; long start, end; char ext; FILE *fpREAD1; FILE *fpREAD2; FILE *fpWRITE; clrscr(); printf("\n WARNING: RESIZING FILES CAN MAKE A FILE UN-OPENABLE"); do { printf("\n Enter First Filename Using 8.3 limit: "); scanf("%12s", &input1file); if ( fopen(input1file,"rb") ) break; else printf(" %s <-- No Such File, Try Again!", input1file); } while ( 1 ); do { printf(" Enter Second Filename Using 8.3 limit: "); scanf("%12s", &input2file); if ( fopen(input2file,"rb") ) break; else printf(" %s <-- No Such File, Try Again!\n", input2file); } while ( 1 ); createfilename(); printf(" Outputting to: %s", outputfile); do { printf("\n "); for ( i=0 ; i<38 ; i++ ) printf("- "); fpREAD1 = fopen(input1file,"rb"); fpREAD2 = fopen(input2file,"rb"); fpWRITE = fopen(outputfile,"wb"); fseek(fpREAD1, 0, SEEK_END); file1size = ftell(fpREAD1); rewind(fpREAD1); fseek(fpREAD2, 0, SEEK_END); file2size = ftell(fpREAD2); rewind(fpREAD2); printf("\n %12s Filesize = %ld", input1file, file1size); printf("\n %12s Filesize = %ld", input2file, file2size); printf("\n %12s ", input1file); percent = 0; for ( i=0 ; i < file1size ; i++ ) { fread(&sym, 1, 1, fpREAD1); fwrite(&sym, 1, 1, fpWRITE); if ( 100*i/file1size > percent ) { percent++; showpercent(percent); } } while (percent < 100 ) showpercent(++percent); printf("\n %12s ", input2file); percent = 0; for ( i=0 ; i < file2size ; i++ ) { fread(&sym, 1, 1, fpREAD2); fwrite(&sym, 1, 1, fpWRITE); if ( 100*i/file2size > percent ) { percent++; showpercent(percent); } } while (percent < 100 ) showpercent(++percent); printf("\n Done"); file3size = ftell(fpWRITE); printf("\n The Final Filesize = %ld", file3size); printf("\n Filesize should be = %ld", file1size + file2size); fclose(fpREAD1); fclose(fpREAD2); fclose(fpWRITE); printf("\n Would you like to Recopy? Y/N"); ext = getch(); } while ( ext != 'n' && ext != 'N' ); return 0; } void showpercent(int percent) { if( percent % 2 == 0) { mark++; if ( mark % 2 == 0) { printf("%c",223); } else { printf("%c",220); } printf(" %3d%%", percent); printf("\b\b\b\b\b"); } } void createfilename() { int i; for ( i=0 ; i<13 ; i++ ) { if ( input1file[i] == '.' ) break; else outputfile[i] = 'O'; } while ( i<13 && input1file[i] != '\n') { outputfile[i] = input1file[i]; i++; } }