mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 07:34:27 +00:00
ntdll: Add _wmakepath_s.
Implementation copied from msvcrt. Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5d2f0688cf
commit
0c986b2c77
|
@ -1555,6 +1555,7 @@
|
|||
@ cdecl -ret64 _wcstoui64(wstr ptr long)
|
||||
@ cdecl _wcsupr(wstr)
|
||||
@ cdecl _wcsupr_s(wstr long)
|
||||
@ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr)
|
||||
@ cdecl _wsplitpath_s(wstr ptr long ptr long ptr long ptr long)
|
||||
@ cdecl _wtoi(wstr)
|
||||
@ cdecl -ret64 _wtoi64(wstr)
|
||||
|
|
|
@ -1375,3 +1375,80 @@ error:
|
|||
if (ext) ext[0]= 0;
|
||||
return ERANGE;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* _wmakepath_s (NTDLL.@)
|
||||
*/
|
||||
errno_t __cdecl _wmakepath_s( wchar_t *path, size_t size, const wchar_t *drive,
|
||||
const wchar_t *directory, const wchar_t *filename,
|
||||
const wchar_t *extension )
|
||||
{
|
||||
wchar_t *p = path;
|
||||
|
||||
if (!path || !size) return EINVAL;
|
||||
|
||||
if (drive && drive[0])
|
||||
{
|
||||
if (size <= 2) goto range;
|
||||
*p++ = drive[0];
|
||||
*p++ = ':';
|
||||
size -= 2;
|
||||
}
|
||||
|
||||
if (directory && directory[0])
|
||||
{
|
||||
unsigned int len = wcslen(directory);
|
||||
unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\';
|
||||
unsigned int copylen = min(size - 1, len);
|
||||
|
||||
if (size < 2) goto range;
|
||||
memmove(p, directory, copylen * sizeof(wchar_t));
|
||||
if (size <= len) goto range;
|
||||
p += copylen;
|
||||
size -= copylen;
|
||||
if (needs_separator)
|
||||
{
|
||||
if (size < 2) goto range;
|
||||
*p++ = '\\';
|
||||
size -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (filename && filename[0])
|
||||
{
|
||||
unsigned int len = wcslen(filename);
|
||||
unsigned int copylen = min(size - 1, len);
|
||||
|
||||
if (size < 2) goto range;
|
||||
memmove(p, filename, copylen * sizeof(wchar_t));
|
||||
if (size <= len) goto range;
|
||||
p += len;
|
||||
size -= len;
|
||||
}
|
||||
|
||||
if (extension && extension[0])
|
||||
{
|
||||
unsigned int len = wcslen(extension);
|
||||
unsigned int needs_period = extension[0] != '.';
|
||||
unsigned int copylen;
|
||||
|
||||
if (size < 2) goto range;
|
||||
if (needs_period)
|
||||
{
|
||||
*p++ = '.';
|
||||
size -= 1;
|
||||
}
|
||||
copylen = min(size - 1, len);
|
||||
memcpy(p, extension, copylen * sizeof(wchar_t));
|
||||
if (size <= len) goto range;
|
||||
p += copylen;
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return 0;
|
||||
|
||||
range:
|
||||
path[0] = 0;
|
||||
return ERANGE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue