[Previous]
[Contents]
[Next]

_fullpath()

return the full pathname of a file

Synopsis:

#include <stdlib.h>
char *_fullpath( char *buffer,
                 const char *path,
                 size_t size );

Description:

The _fullpath() function returns the full pathname of the file specification in path in the specified buffer buffer of length size.

The maximum size that might be required for buffer is _MAX_PATH. If the buffer provided is too small, NULL is returned, and errno is set.

If buffer is NULL, then a buffer of size _MAX_PATH is allocated using malloc(). This buffer may be freed using the free() function.

If path is NULL or points to a null string ("") then the current working directory is returned in buffer.

Returns:

A pointer to the full path specification. If an error occurs, _fullpath() returns NULL and errno indicates the type of error detected.

Errors:

ENOENT
The current working directory couldn't be obtained.
ENOMEM
The buffer couldn't be allocated.
ERANGE
The buffer passed was too small.

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

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

    for( i = 1; i < argc; ++i ) {
      puts( argv[i] );
      if( _fullpath( buff, argv[i], PATH_MAX ) ) {
        puts( buff );
      } else {
        puts( "FAIL!" );
      }
    }
  }

Classification:

WATCOM

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

errno, _makepath(), _splitpath()


[Previous]
[Contents]
[Next]