home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
disks
/
misc
/
disksplit
/
source
/
diskjoin
/
diskjoin.c
next >
Wrap
C/C++ Source or Header
|
1996-05-07
|
1KB
|
96 lines
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef min
#define min(a,b) ((a)<=(b)?(a):(b))
#endif
char VerStr[] = "$VER: DiskJoin 1.0 (7.5.96)";
#define BUFSIZE 50000
int main( int argv, char **arg )
{
long read;
char *name = 0;
short f, vol;
FILE *In, *Out = 0;
char *Buf, namebuf[30], *pnt, faul;
if( argv < 2 ) {
Info:
printf( "DiskJoin v1.0 (7.5.96)\nJoin files created by DiskSplit\n\n Usage: DiskJoin filebase\n\n" );
return( 20 );
} else {
for( f = 1; f < argv; f++ ) {
name = arg[f];
}
if( !name ) goto Info;
if( !(Buf = malloc( BUFSIZE )) ) {
printf( "Can not alloc %d bytes buffer\n", (int)BUFSIZE );
return( 20 );
}
vol = 0;
if( !(Out = fopen( name, "ab" )) ) {
printf( "Can not open file for writing\n" );
return( 20 );
}
faul = 0;
while( 1 ) {
strcpy( namebuf, name );
for( pnt = namebuf; ; pnt++ ) {
if( !*pnt ) {
*(pnt++) = '.';
break;
}
else if( *pnt == '.' ) {
pnt++;
if( *pnt ) pnt++;
break;
}
}
sprintf( pnt, "%02hd", vol );
In = fopen( namebuf, "rb" );
if( In ) {
faul = 0;
printf( "Processing: %s\n", namebuf );
while( read = fread( Buf, 1, BUFSIZE, In ) ) {
if( read != fwrite( Buf, 1, read, Out ) ) {
printf( "Problems with output\n" );
return( 20 );
}
}
fclose( In );
remove( namebuf );
} else {
if( faul>1 ) break;
faul++;
}
vol++;
}
}
return 0;
}