return the full pathname of a file
#include <stdlib.h>
char *_fullpath( char *buffer,
const char *path,
size_t size );
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.
A pointer to the full path specification. If an error occurs, _fullpath() returns NULL and errno indicates the type of error detected.
#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!" );
}
}
}
WATCOM
| Safety: | |
|---|---|
| Interrupt handler | Yes |
| Signal handler | Yes |
| Thread | Yes |
errno, _makepath(), _splitpath()