www.delorie.com/djgpp/doc/libc/libc_39.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

access

Syntax

 
#include <unistd.h>

int access(const char *filename, int flags);

Description

This function determines what kind of access modes a given file allows. The parameter flags is the logical or of one or more of the following flags:

R_OK

Request if the file is readable. Since all files are readable under MS-DOS, this access mode always exists.

W_OK

Request if the file is writable.

X_OK

Request if the file is executable.

F_OK

Request if the file exists.

D_OK

Request if the file is really a directory.

Return Value

Zero if the requested access mode is allowed, nonzero if not.

Portability

ANSI/ISO C No
POSIX 1003.2-1992; 1003.1-2001

Example

 
if (access("file.ext", W_OK))
  return ERROR_CANNOT_WRITE;
open("file.ext", O_RDWR);


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004