_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:

The _fullpath() function returns a pointer to the full path specification if no error occurred. Otherwise, NULL is returned, and the global varaible errno contains a value to indicate the type of error that was detected.

Errors:

ENOENT
The current working directory could not be obtained.
ENOMEM
The buffer could not be allocated.
ERANGE
The buffer passed was too small.

See also:

errno, _makepath(), _splitpath()

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

Systems:

All (except DOS/PM)