2 * PROJECT: ReactOS CRT library
3 * LICENSE: See COPYING in the top level directory
4 * FILE: lib/sdk/crt/stdlib/makepath_s.c
5 * PURPOSE: Creates a path
6 * PROGRAMMERS: Wine team
7 * Copyright 1996,1998 Marcus Meissner
8 * Copyright 1996 Jukka Iivonen
9 * Copyright 1997,2000 Uwe Bonnes
10 * Copyright 2000 Jon Griffiths
18 /*********************************************************************
19 * _makepath_s (MSVCRT.@)
21 * Safe version of _makepath.
23 int CDECL
_makepath_s(char *path
, size_t size
, const char *drive
,
24 const char *directory
, const char *filename
,
25 const char *extension
)
35 if (drive
&& drive
[0])
45 if (directory
&& directory
[0])
47 unsigned int len
= strlen(directory
);
48 unsigned int needs_separator
= directory
[len
- 1] != '/' && directory
[len
- 1] != '\\';
49 unsigned int copylen
= min(size
- 1, len
);
54 memmove(p
, directory
, copylen
);
72 if (filename
&& filename
[0])
74 unsigned int len
= strlen(filename
);
75 unsigned int copylen
= min(size
- 1, len
);
80 memmove(p
, filename
, copylen
);
89 if (extension
&& extension
[0])
91 unsigned int len
= strlen(extension
);
92 unsigned int needs_period
= extension
[0] != '.';
104 copylen
= min(size
- 1, len
);
105 memcpy(p
, extension
, copylen
);