Borland C++ reference

_makepath

raw OCR

Builds a path from component parts.

Defined in header <stdlib.h>

Syntax

#include <stdlib.h>
void _makepath(char   *path, const char *drive, const char *dir,
const char *name, const char *ext);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

_makepath makes a path name from its components. The new path name

.

is

X:\DIR\SUBDIR\NAME.EXT where

drive-X:

dir=\DIR\SUBDIR\

name=NAME

ext=.EXT

If drive is empty or NULL, no drive is inserted in the path name. If it is missing a trailing colon (:), a colon is inserted in the path name.

If dir is empty or NULL, no directory is inserted in the path name. If it is missing a trailing slash (\ or /), a backslash is inserted in the path name.

If name is empty or NULL, no filename is inserted in the path name.

If ext is empty or NULL, no extension is inserted in the path name. If it is missing a leading period (.), a period is inserted in the path name.

_makepath assumes there is enough space in path for the constructed path

name. The maximumconstructed length is _MAX_PATH._MAX_PATH

is defined in stdlib.h. _makepath and _splitpath are invertible; if you split a given path with _splitpath, then merge the resultant components with _makepath, you end up with path.

Return value

None.

See also

Example

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

int main(void)

   char s[_MAX_PATH];
   char drive [_MAX_DRIVE];
   char dir[_MAX_DIR] ;
   char file[_MAX_FNAME];
   char ext [_MAX_EXT];
   getcwd(s,_MAX_PATH) ;           /* get current working directory  */
   if (s[strlen(s)-l]  != '\\')
      strcat (s,"\\");             /  append a trailing \ character  */
   _splitpath (s,drive,dir,file,ext)  /* split the string to separate elems
   strcpy(file,"DATA") ;
   strcpy(ext,".TXT") ;
   _makepath(s,drive,dir, file,ext); /* merge everything into one string  */
   puts(s);                        /■ display resulting string */
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `_nnakepath` read as `_makepath`