#include #include #include #include #include #include #include #include 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); }