[Previous]
[Contents]
[Next]

qnx_fullpath()

find the full path for a file or directory

Synopsis:

#include <unistd.h>
char *qnx_fullpath( char *fullpath, 
                    const char *path )

Description:

The qnx_fullpath() function expands the pathname path into the buffer provided by fullpath. The new path is fully qualified, and unique to the network. The full path consists of the following components:

//node/path

where:

//
is network root specifier
node
is a decimal number
path
is a path on that device (for example, home/dtdodge/data).

For example:

Path Full Path
data //4/home/dtdodge/data
/home/dtdodge/data //4/home/dtdodge/data

Note: The buffer pointed to by fullpath must be at least PATH_MAX+1 characters in length.

This function is useful if a user gives a file name that must be passed to another process that may be running on another node with a different current directory and search order for pathname resolution.


Note: The qnx_fullpath() function succeeds whether the file exists or not, but fails if any intermediate directories in the path don't exist. The access() function can be used to test for the actual existence of the file.

Returns:

fullpath if the pathname is successfully built. On error, NULL is returned, and errno is set.


Note: The returned fullpath string never has a trailing slash.

Errors:

ENOMEM
The calling process doesn't have enough memory to calloc() a temporary buffer.

In addition, qnx_fullpath() may set errno to any of the values listed for open(), qnx_fd_attach() and qnx_vc_attach().

Examples:

/*
 * This program prints out the full pathname of
 * each of its arguments.
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>

void main( int argc, char **argv )
  {
    int i;
    char pathname[PATH_MAX+1];

    for( i = 1; i < argc; i++ ) {
      if( qnx_fullpath( pathname, argv[i] ) == NULL ) {
      perror( argv[i] );
      } else {
      printf( "%s\n", pathname );
      }
    }
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

access(), errno, qnx_fd_attach(), qnx_vc_attach(), open()


[Previous]
[Contents]
[Next]