fnmerge, _wfnmerge

De RAD Studio
Aller à : navigation, rechercher

Remonter à Dir.h - Index


Header File

dir.h

Category

Directory Control Routines

Prototype

void fnmerge(char *path, const char *drive, const char *dir, const char *name, const char *ext);

void _wfnmerge(wchar_t *path, const wchar_t *drive, const wchar_t *dir, const wchar_t *name, const wchar_t *ext );

Description

Builds a path from component parts.

fnmerge 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 file name 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.

fnmerge assumes there is enough space in path for the constructed path name. The maximum constructed length is MAXPATH. MAXPATH is defined in dir.h.

fnmerge and fnsplit are invertible; if you split a given path with fnsplit then merge the resultant components with fnmerge you end up with path.

Return Value

None.

Example



 #include <string.h>
 #include <stdio.h>
 #include <dir.h>
 int main(void)
 {
    char s[MAXPATH];
    char drive[MAXDRIVE];
    char dir[MAXDIR];
    char file[MAXFILE];
    char ext[MAXEXT];
    getcwd(s,MAXPATH);              /* get the current working directory */
    strcat(s,"\\");                 /* append on a trailing character */
    fnsplit(s,drive,dir,file,ext);  /* split the string to separate elems */
    strcpy(file,"DATA");
    strcpy(ext,".TXT");
    fnmerge(s,drive,dir,file,ext);   /* merge everything into one string */
    puts(s);                         /* display resulting string */
    return 0;
 }



Portability



POSIX Win32 ANSI C ANSI C++

fnmerge

+

_wfnmerge

NT only