RAD Studio
ContentsIndex
PreviousUpNext
_fullpath, _wfullpath

Header File 

stdlib.h  

Category 

Directory Control Routines 

Prototype 

char * _fullpath(char *buffer, const char *path, int buflen); 

wchar_t * _wfullpath(wchar_t *buffer, const wchar_t *path, int buflen); 

Description 

Converts a path name from relative to absolute. 

_fullpath converts the relative path name in path to an absolute path name that is stored in the array of characters pointed to by buffer. The maximum number of characters that can be stored at buffer is buflen. The function returns NULL if the buffer isn't big enough to store the absolute path name or if the path contains an invalid drive letter. 

If buffer is NULL, _fullpath allocates a buffer of up to _MAX_PATH characters. This buffer should be freed using free when it is no longer needed. _MAX_PATH is defined in stdlib.h. 

Return Value 

If successful the _fullpath function returns a pointer to the buffer containing the absolute path name. 

On error, this function returns NULL. 

Example  

#include <stdio.h>
#include <stdlib.h>
char buf[_MAX_PATH];
void main(int argc, char *argv[])
{
  for ( ; argc; argv++, argc--)
  {
    if (_fullpath(buf, argv[0], _MAX_PATH) == NULL)
      printf("Unable to obtain full path of %s\n",argv[0]);
    else
      printf("Full path of %s is %s\n",argv[0],buf);
  }
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
_fullpath 
 
 
 
_wfullpath 
 
NT only 
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!