:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / msvcrt / stdlib / makepath.c
1 /* $Id$
2  */
3 #include <msvcrt/stdlib.h>
4 #include <msvcrt/string.h>
5
6 void _makepath(char *path, const char *drive, const char *dir, const char *fname, const char *ext)
7 {
8   int dir_len;
9
10   if ((drive != NULL) && (*drive))
11     {
12       strcpy(path, drive);
13       strcat(path, ":");
14     }
15   else
16     (*path)=0;
17
18   if (dir != NULL)
19     {
20       strcat(path, dir);
21       dir_len = strlen(dir);
22       if (dir_len && *(dir + dir_len - 1) != '\\')
23         strcat(path, "\\");
24     }
25
26   if (fname != NULL)
27     {
28       strcat(path, fname);
29       if (ext != NULL && *ext != 0)
30         {
31           if (*ext != '.')
32             strcat(path, ".");
33         strcat(path, ext);
34         }
35     }
36 }
37
38
39 void _wmakepath(wchar_t *path, const wchar_t *drive, const wchar_t *dir, const wchar_t *fname, const wchar_t *ext)
40 {
41   int dir_len;
42
43   if ((drive != NULL) && (*drive))
44     {
45       wcscpy(path, drive);
46       wcscat(path, L":");
47     }
48   else
49     (*path)=0;
50
51   if (dir != NULL)
52     {
53       wcscat(path, dir);
54       dir_len = wcslen(dir);
55       if (dir_len && *(dir + dir_len - 1) != L'\\')
56         wcscat(path, L"\\");
57     }
58
59   if (fname != NULL)
60     {
61       wcscat(path, fname);
62       if (ext != NULL && *ext != 0)
63         {
64           if (*ext != L'.')
65             wcscat(path, L".");
66           wcscat(path, ext);
67         }
68     }
69 }