home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 31
/
CDASC_31_1996_juillet_aout.iso
/
internet
/
wsplug31.zip
/
SCOPY.C
< prev
next >
Wrap
Text File
|
1996-02-06
|
1KB
|
63 lines
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <share.h>
extern int errno;
main(argc,argv)
int argc;
char **argv;
{ int hs,hd,more=1 ;
char buf[512] ;
if (argc < 3)
{ printf("Missing arguments ... \n");
printf("scopy source_file target_file \n");
return(0);
}
while(more)
{
hs = open(argv[1],O_BINARY|O_RDONLY);
if (hs == -1)
{ if (errno != EACCES)
{ printf("Unable to Open [errno=%d]%s...\n",errno,argv[1]);
return(0) ;
}
else printf("Scopy, File %s Permission Denied...\n",argv[1]);
}
else more=0;
}
more=1;
while(more)
{
hd = sopen(argv[2],O_BINARY|O_RDWR|O_CREAT|O_TRUNC,SH_DENYRW,S_IREAD|S_IWRITE);
if (hd == -1)
{ if (errno != EACCES)
{ printf("Unable to Open [errno=%d]%s...\n",errno,argv[2]);
close(hs) ;
return(0) ;
}
else printf("File %s Permission Denied...\n",argv[1]);
}
else more=0;
}
more = 1;
while(more)
{ more= read(hs,buf,512) ;
if (more >0) more = write(hd,buf,more) ;
}
close(hs) ;
close (hd) ;
return(0);
}