xref: /reactos/sdk/lib/crt/stdlib/makepath.c (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * PROJECT:     ReactOS CRT library
3*c2c66affSColin Finck  * LICENSE:     See COPYING in the top level directory
4*c2c66affSColin Finck  * FILE:        lib/sdk/crt/stdlib/makepath.c
5*c2c66affSColin Finck  * PURPOSE:     Creates a path
6*c2c66affSColin Finck  * PROGRAMMERS: Wine team
7*c2c66affSColin Finck  *              Copyright 1996,1998 Marcus Meissner
8*c2c66affSColin Finck  *              Copyright 1996 Jukka Iivonen
9*c2c66affSColin Finck  *              Copyright 1997,2000 Uwe Bonnes
10*c2c66affSColin Finck  *              Copyright 2000 Jon Griffiths
11*c2c66affSColin Finck  *
12*c2c66affSColin Finck  */
13*c2c66affSColin Finck 
14*c2c66affSColin Finck #include <precomp.h>
15*c2c66affSColin Finck #include <stdlib.h>
16*c2c66affSColin Finck #include <string.h>
17*c2c66affSColin Finck 
18*c2c66affSColin Finck /*
19*c2c66affSColin Finck  * @implemented
20*c2c66affSColin Finck  */
_makepath(char * path,const char * drive,const char * dir,const char * fname,const char * ext)21*c2c66affSColin Finck void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
22*c2c66affSColin Finck {
23*c2c66affSColin Finck     char *p = path;
24*c2c66affSColin Finck 
25*c2c66affSColin Finck     if ( !path )
26*c2c66affSColin Finck         return;
27*c2c66affSColin Finck 
28*c2c66affSColin Finck     if (drive && drive[0])
29*c2c66affSColin Finck     {
30*c2c66affSColin Finck         *p++ = drive[0];
31*c2c66affSColin Finck         *p++ = ':';
32*c2c66affSColin Finck     }
33*c2c66affSColin Finck     if (dir && dir[0])
34*c2c66affSColin Finck     {
35*c2c66affSColin Finck         size_t len = strlen(dir);
36*c2c66affSColin Finck         memmove(p, dir, len);
37*c2c66affSColin Finck         p += len;
38*c2c66affSColin Finck         if (p[-1] != '/' && p[-1] != '\\')
39*c2c66affSColin Finck             *p++ = '\\';
40*c2c66affSColin Finck     }
41*c2c66affSColin Finck     if (fname && fname[0])
42*c2c66affSColin Finck     {
43*c2c66affSColin Finck         size_t len = strlen(fname);
44*c2c66affSColin Finck         memmove(p, fname, len);
45*c2c66affSColin Finck         p += len;
46*c2c66affSColin Finck     }
47*c2c66affSColin Finck     if (ext && ext[0])
48*c2c66affSColin Finck     {
49*c2c66affSColin Finck         if (ext[0] != '.')
50*c2c66affSColin Finck             *p++ = '.';
51*c2c66affSColin Finck         strcpy(p, ext);
52*c2c66affSColin Finck     }
53*c2c66affSColin Finck     else
54*c2c66affSColin Finck         *p = '\0';
55*c2c66affSColin Finck }
56