[Previous]
[Contents]
[Next]

_makepath()

construct a full pathname

Synopsis:

#include <stdlib.h>

void _makepath( char *path,
                const char *node,
                const char *dir,
                const char *fname,
                const char *ext );

Description:

The _makepath() function constructs a full pathname from the components consisting of a

The full pathname (for example, //2/home/fred/myfile.dat) is placed in the buffer pointed to by the argument path.

The maximum size required for each buffer is specified by the manifest constants _MAX_PATH, _MAX_NODE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT, which are defined in <stdlib.h>.

The arguments to this function are as follows:

node
The node argument points to a buffer containing the node specification (for example, //0, //1, and so on.), followed by an optional /. The _makepath() function automatically inserts a / following the node number in the full pathname if it's missing. If node is a NULL pointer, or points to an empty string, no node specification is placed in the full pathname.
dir
The dir argument points to a buffer containing just the pathname. The trailing slash is optional. The _makepath() function automatically inserts a trailing slash in the full pathname if it's missing. If dir is a NULL pointer, or points to an empty string, no slash is placed in the full pathname.
fname
The fname argument points to a buffer containing the base name of the file without any extension (suffix).
ext
The ext argument points to a buffer containing the filename extension or suffix. A leading period (.) is optional. The _makepath() routine automatically inserts a period in the full pathname if it is missing. If ext is a NULL pointer, or points to an empty string, no period is placed in the full pathname.

Examples:

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

void main()
  {
    char full_path[ _MAX_PATH ];
    char node[ _MAX_NODE ];
    char dir[ _MAX_DIR ];
    char fname[ _MAX_FNAME ];
    char ext[ _MAX_EXT ];

    _makepath(full_path,"//0","/home/fred/h","stdio","h");
    printf( "Full path is: %s\n\n", full_path );
    _splitpath( full_path, node, dir, fname, ext );
    printf( "Components after _splitpath\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 _splitpath
node:  //0
dir:   /home/fred/h/
fname: stdio
ext:   .h

Classification:

WATCOM

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

_fullpath(), _splitpath()


[Previous]
[Contents]
[Next]