home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / internet / wsplug31.zip / TEST&LCK.C < prev    next >
Text File  |  1996-02-06  |  717b  |  38 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.  
  17.   if (argc < 2)
  18.   { printf("test&lck filename\n");return(0);}
  19.  
  20.   while(more)
  21.   {
  22.   h = open(argv[1],O_RDWR|O_CREAT,SH_DENYRD,S_IREAD|S_IWRITE) ;
  23.   if (h == -1)
  24.   { if (errno != EACCES)
  25.       { printf("Unable to Open %s...\n",argv[1]);
  26.     return(0) ;
  27.       }
  28.       else printf("File %s Permision denied...\n",argv[1]);
  29.   }
  30.   else  { printf("File %s is locked, RETURN to continue\n",argv[1]);
  31.       getchar(); close(h) ;more=0;}
  32.   }
  33.  
  34.   return(0);
  35.  
  36. }
  37.  
  38.