home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / internet / wsplug31.zip / VCOPY.C < prev    next >
Text File  |  1996-02-06  |  775b  |  41 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <io.h>
  4. #include <errno.h>
  5. #include <string.h>
  6. #include <fcntl.h>
  7. #include <sys/stat.h>
  8. #include <share.h>
  9.  
  10. extern int errno;
  11.  
  12. main(argc,argv)
  13. int argc;
  14. char **argv;
  15. { int h,more=1 ;
  16.   if (argc < 2)
  17.   { printf("Missing arguments ... \n");
  18.     printf("vcopy string filename\n");
  19.     return(0);
  20.   }
  21.  
  22.   while(more)
  23.   {
  24.   h = sopen(argv[2],O_BINARY|O_CREAT|O_WRONLY|O_TRUNC,SH_DENYRW,S_IREAD|S_IWRITE);
  25.   if (h == -1)
  26.     { if (errno != EACCES)
  27.       { printf("Unable to Open %s...\n",argv[2]);
  28.     return(0) ;
  29.       }
  30.       else printf("Vcopy, File %s Permission Denied...\n",argv[2]);
  31.     }
  32.    else more=0;
  33.   }
  34.  
  35.   if (argc > 2) write(h,argv[1],strlen(argv[1]));
  36.   close(h) ;
  37.   return(0);
  38.  
  39. }
  40.  
  41.