home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpm
/
bdsc-4
/
bdslib.ark
/
FACCESS.C
< prev
next >
Wrap
Text File
|
1983-07-15
|
1KB
|
31 lines
/*
* Faccess
* Based roughly on the U**X system call, it accepts a filename
* and a mode (0 - exists, 2 - write, and 4 - read). If the test
* is successful 0 returned. If the test is unsuccessful or the
* file could not be found -1 is returned. This helps to remedy
* some of the 'Bdos Err On A: File R/O' ugliness.
* Edit of 7/1/83
*/
faccess(name,mode)
char *name;
int mode;
{
char *byte, c;
fcb address;
setfcb(address,name);
if ((c=bdos(17,&address)) == 255)
return ERROR; /* file not found */
byte =(0x80 + (c * 32) + _MBYTE); /* permission byte */
if (mode == 0) return 0; /* file exists */
if ((*byte & '\200') == 0) {
if (mode == 1) return 0; /* execute permission */
if (mode == 2) return 0; /* write permission */
if (mode == 4) return 0; /* read permission */
}
else if (mode == 2) return ERROR; /* readonly file */
else return ERROR; /* unknown mode */
}