access

Determines whether a file or directory exists and if it can be accessed

Local Servers:blocking
Remote Servers:blocking
Classification:POSIX
Platform:NLM
Service:File System

Syntax

   #include <unistd.h>  
    
   int access  (  
      const char  *path,   
      int          mode); 
   

Parameters

path

(IN) Specifies the string containing the path that includes the file or directory to be accessed (maximum 255 characters, including the NULL terminator).

mode

(IN) Specifies the access permission mode for the file.

Return Values

Returns 0 if the file or directory exists and can be accessed with the specified mode. Otherwise, it returns a value of -1. If an error occurs, the errno parameter is set.

Remarks

access also works on the DOS partition.

access determines if the file or directory specified by the path parameter exists and if it can be accessed with the file permission given by the mode parameter.

When the mode parameter is 0, only the existence of the file is verified. The read and/or write and/or execute permission for the file can be determined when the bits of the mode parameter are a combination of the following:

0

F_OK: File existence

1

X_OK: Execute permission

2

W_OK: Write permission

4

R_OK: Read permission

The result is dependent on the current connection number.

The SetCurrentNameSpace function sets the name space which is used for parsing the path input to this function.

NOTE:For NetWare® versions before 4.x, access works with only the DOS name space for remote servers.

See Using access(): Example (NDK: Sample Code).

See Also

chmod, fstat (Single and Intra-File Services)