home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d110
/
pdc.lha
/
Pdc
/
examples
/
cp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-10-28
|
1KB
|
51 lines
#define NULL 0
#define BUFLEN 1024
#define MODE_NEWFILE 1006
#define MODE_OLDFILE 1005
main(argc, argv)
int argc;
char **argv;
{
/* Test AmigaDos File I/O */
int i;
long fromfile, tofile; /* Bptr from Open */
long length;
char buffer[BUFLEN];
char *fromname, *toname;
extern long Open(), Read(), Write();
if (argc != 3)
{
printf("Useage: Copy fromfile tofile");
exit(4);
}
fromfile = Open(argv[1], MODE_OLDFILE);
printf("%s opened with result %ld\n", argv[1], fromfile);
if (fromfile == NULL )
{
printf("Can't open: %s\n", argv[1]);
exit(4);
}
tofile = Open(argv[2], MODE_NEWFILE);
printf("%s opened with result %ld\n", argv[2], tofile);
if (tofile == NULL )
{
printf("Can't open: %s\n", argv[2]);
exit(4);
}
length = Read( fromfile, buffer, BUFLEN );
while ( length > 0 )
{
Write( tofile, buffer, length);
length = Read( fromfile, buffer, BUFLEN );
}
Close( fromfile);
Close( tofile );
exit(0);
}