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 >
Wrap
Text File
|
1996-02-06
|
717b
|
38 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 h,more=1 ;
if (argc < 2)
{ printf("test&lck filename\n");return(0);}
while(more)
{
h = open(argv[1],O_RDWR|O_CREAT,SH_DENYRD,S_IREAD|S_IWRITE) ;
if (h == -1)
{ if (errno != EACCES)
{ printf("Unable to Open %s...\n",argv[1]);
return(0) ;
}
else printf("File %s Permision denied...\n",argv[1]);
}
else { printf("File %s is locked, RETURN to continue\n",argv[1]);
getchar(); close(h) ;more=0;}
}
return(0);
}