- Update _makepath and _wmakepath to allow in place operation and separated extension processing, based on wine code

- Fixes all 14 msvcrt dir winetests

svn path=/trunk/; revision=38050
This commit is contained in:
Gregor Schneider 2008-12-13 21:06:47 +00:00
parent 1e4507a141
commit 681e0e0b24
2 changed files with 79 additions and 49 deletions

View file

@ -1,3 +1,16 @@
/*
* PROJECT: ReactOS CRT library
* LICENSE: See COPYING in the top level directory
* FILE: lib/sdk/crt/stdlib/makepath.c
* PURPOSE: Creates a path
* PROGRAMMERS: Wine team
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
*
*/
/* $Id$
*/
#include <precomp.h>
@ -9,29 +22,36 @@
*/
void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
{
int dir_len;
char *p = path;
if ((drive != NULL) && (*drive)) {
path[0] = *drive;
path[1] = ':';
path[2] = 0;
} else {
(*path)=0;
}
if ( !path )
return;
if (dir != NULL) {
strcat(path, dir);
dir_len = strlen(dir);
if (dir_len && *(dir + dir_len - 1) != '\\')
strcat(path, "\\");
if (drive && drive[0])
{
*p++ = drive[0];
*p++ = ':';
}
if (fname != NULL) {
strcat(path, fname);
if (ext != NULL && *ext != 0) {
if (*ext != '.')
strcat(path, ".");
strcat(path, ext);
}
if (dir && dir[0])
{
unsigned int len = strlen(dir);
memmove(p, dir, len);
p += len;
if (p[-1] != '/' && p[-1] != '\\')
*p++ = '\\';
}
if (fname && fname[0])
{
unsigned int len = strlen(fname);
memmove(p, fname, len);
p += len;
}
if (ext && ext[0])
{
if (ext[0] != '.')
*p++ = '.';
strcpy(p, ext);
}
else
*p = '\0';
}

View file

@ -1,11 +1,14 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/??????
* PURPOSE: Unknown
* PROGRAMER: gdalsnes
* UPDATE HISTORY:
* 25/11/05: Added license header
* PROJECT: ReactOS CRT library
* LICENSE: See COPYING in the top level directory
* FILE: lib/sdk/crt/stdlib/wmakpath.c
* PURPOSE: Creates a unicode path
* PROGRAMMERS: Wine team
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
*
*/
/* $Id$
@ -17,29 +20,36 @@
*/
void _wmakepath(wchar_t* path, const wchar_t* drive, const wchar_t* dir, const wchar_t* fname, const wchar_t* ext)
{
int dir_len;
wchar_t *p = path;
if ((drive != NULL) && (*drive)) {
path[0] = *drive;
path[1] = L':';
path[2] = 0;
} else {
(*path) = 0;
}
if ( !path )
return;
if (dir != NULL) {
wcscat(path, dir);
dir_len = wcslen(dir);
if (dir_len && *(dir + dir_len - 1) != L'\\')
wcscat(path, L"\\");
if (drive && drive[0])
{
*p++ = drive[0];
*p++ = ':';
}
if (fname != NULL) {
wcscat(path, fname);
if (ext != NULL && *ext != 0) {
if (*ext != L'.')
wcscat(path, L".");
wcscat(path, ext);
}
if (dir && dir[0])
{
unsigned int len = strlenW(dir);
memmove(p, dir, len * sizeof(wchar_t));
p += len;
if (p[-1] != '/' && p[-1] != '\\')
*p++ = '\\';
}
if (fname && fname[0])
{
unsigned int len = strlenW(fname);
memmove(p, fname, len * sizeof(wchar_t));
p += len;
}
if (ext && ext[0])
{
if (ext[0] != '.')
*p++ = '.';
strcpyW(p, ext);
}
else
*p = '\0';
}