home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
rsys-1.3.lha
/
RSys
/
Goodies
/
MyJoin
/
MyJoin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-28
|
2KB
|
101 lines
#include <string.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <dos/stdio.h>
struct Library *DosBase = NULL;
BPTR stdout;
LONG SizeOfFile( char *Name )
{
BPTR lock;
struct FileInfoBlock *InfoBlock;
LONG Size = 0L;
if( InfoBlock = (struct FileInfoBlock *)
AllocVec(sizeof(struct FileInfoBlock),MEMF_CLEAR) )
{
if( lock = Lock( (STRPTR)Name,ACCESS_READ ) )
{
if( Examine( lock,InfoBlock ) )
Size = InfoBlock->fib_Size;
UnLock( lock );
}
FreeVec( InfoBlock );
}
return( Size );
}
void
main(int argc,char *argv[])
{
register int i;
BPTR out,in;
UBYTE *buffer;
long size;
if(DosBase = OpenLibrary((STRPTR)"dos.library",37))
{
stdout = Output();
if(argc >= 3)
{
if(out = Open((STRPTR)argv[1],MODE_NEWFILE))
{
for(i = 2; i < argc; i++)
if(in = Open((STRPTR)argv[i],MODE_OLDFILE))
{
size = SizeOfFile(argv[i]);
buffer = AllocVec(size+2,MEMF_CLEAR|MEMF_ANY);
if(buffer)
{
Read(in,buffer,size);
Write(out,buffer,size);
FreeVec(buffer);
Write(out,(STRPTR)"\n",1);
Printf((STRPTR)"File %s written...\n",(ULONG)argv[i]);
}
else
{
PutStr((STRPTR)"No memory available!\n");
break;
}
Close(in);
}
else
{
Printf((STRPTR)"Error opening %s...", (ULONG)argv[i]);
break;
}
Close(out);
}
else
Printf((STRPTR)"Error opening %s...", (ULONG)argv[1]);
}
else
Printf((STRPTR)"Call: %s <ToFile> <File1> <File2> ... <FileN>\n",(ULONG)argv[0]);
CloseLibrary(DosBase);
}
}