split a pathname into node, directory, file name, and extension
#include <stdlib.h>
void _splitpath2( const char *inp,
char *outp, char **node,
char **dir, char **fname,
char **ext );
The _splitpath2() function splits up a full pathname into four components consisting of:
The arguments are as follows:
The arguments node, dir, fname and ext aren't filled in if they're NULL pointers.
For each component of the full pathname that isn't present, its corresponding pointer is set to point at a NULL string ('\0').
This function reduces the amount of memory space required when compared to the _splitpath() function.
#include <stdio.h>
#include <stdlib.h>
void main()
{
char full_path[ _MAX_PATH ];
char tmp_path[ _MAX_PATH2 ];
char *node;
char *dir;
char *fname;
char *ext;
_makepath(full_path,"//0","home/fred/h","stdio","h");
printf( "Full path is: %s\n\n", full_path );
_splitpath2( full_path, tmp_path,
&node, &dir, &fname, &ext );
printf( "Components after _splitpath2\n" );
printf( "node: %s\n", node );
printf( "dir: %s\n", dir );
printf( "fname: %s\n", fname );
printf( "ext: %s\n", ext );
}
produces the output:
Full path is: //0/home/fred/h/stdio.h Components after _splitpath2 node: //0 dir: /home/fred/h/ fname: stdio ext: .h
WATCOM
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
_fullpath(), _makepath(), _splitpath()