cmd: Use _wsplitpath() from msvcrt.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-04-25 22:53:36 -05:00 committed by Alexandre Julliard
parent c3fac6e36c
commit 60b3db6b98
4 changed files with 9 additions and 62 deletions

View File

@ -301,58 +301,6 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
return buf;
}
/* WCMD_splitpath - copied from winefile as no obvious way to use it otherwise */
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext)
{
const WCHAR* end; /* end of processed string */
const WCHAR* p; /* search pointer */
const WCHAR* s; /* copy pointer */
/* extract drive name */
if (path[0] && path[1]==':') {
if (drv) {
*drv++ = *path++;
*drv++ = *path++;
*drv = '\0';
}
} else if (drv)
*drv = '\0';
end = path + lstrlenW(path);
/* search for begin of file extension */
for(p=end; p>path && *--p!='\\' && *p!='/'; )
if (*p == '.') {
end = p;
break;
}
if (ext)
for(s=end; (*ext=*s++); )
ext++;
/* search for end of directory name */
for(p=end; p>path; )
if (*--p=='\\' || *p=='/') {
p++;
break;
}
if (name) {
for(s=p; s<end; )
*name++ = *s++;
*name = '\0';
}
if (dir) {
for(s=path; s<p; )
*dir++ = *s++;
*dir = '\0';
}
}
/****************************************************************************
* WCMD_HandleTildaModifiers
*
@ -627,7 +575,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
BOOL addSpace = (finaloutput[0] != 0x00);
/* Split into components */
WCMD_splitpath(fullfilename, drive, dir, fname, ext);
_wsplitpath(fullfilename, drive, dir, fname, ext);
/* 5. Handle 'd' : Drive Letter */
if (wmemchr(firstModifier, 'd', modifierLen) != NULL) {

View File

@ -1217,7 +1217,7 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
/* Convert path into actual directory spec */
GetFullPathNameW(filename, ARRAY_SIZE(fpath), fpath, NULL);
WCMD_splitpath(fpath, drive, dir, fname, ext);
_wsplitpath(fpath, drive, dir, fname, ext);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */
if ((lstrcmpW(fname, starW) == 0) &&
@ -1352,7 +1352,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
/* Convert path into actual directory spec */
GetFullPathNameW(argCopy, ARRAY_SIZE(thisDir), thisDir, NULL);
WCMD_splitpath(thisDir, drive, dir, fname, ext);
_wsplitpath(thisDir, drive, dir, fname, ext);
lstrcpyW(thisDir, drive);
lstrcatW(thisDir, dir);
@ -2986,7 +2986,7 @@ void WCMD_move (void)
wine_dbgstr_w(param1), wine_dbgstr_w(output));
/* Split into components */
WCMD_splitpath(input, drive, dir, fname, ext);
_wsplitpath(input, drive, dir, fname, ext);
hff = FindFirstFileW(input, &fd);
if (hff == INVALID_HANDLE_VALUE)
@ -3207,7 +3207,7 @@ void WCMD_rename (void)
dotDst = wcschr(param2, '.');
/* Split into components */
WCMD_splitpath(input, drive, dir, fname, ext);
_wsplitpath(input, drive, dir, fname, ext);
hff = FindFirstFileW(input, &fd);
if (hff == INVALID_HANDLE_VALUE)
@ -3492,7 +3492,7 @@ void WCMD_setshow_default (const WCHAR *args) {
/* Convert path into actual directory spec */
GetFullPathNameW(string, ARRAY_SIZE(fpath), fpath, NULL);
WCMD_splitpath(fpath, drive, dir, fname, ext);
_wsplitpath(fpath, drive, dir, fname, ext);
/* Rebuild path */
wsprintfW(string, fmt, drive, dir, fd.cFileName);

View File

@ -166,8 +166,8 @@ static int __cdecl WCMD_dir_sort (const void *a, const void *b)
WCHAR extB[MAX_PATH];
/* Split into components */
WCMD_splitpath(filea->cFileName, drive, dir, fname, extA);
WCMD_splitpath(fileb->cFileName, drive, dir, fname, extB);
_wsplitpath(filea->cFileName, drive, dir, fname, extA);
_wsplitpath(fileb->cFileName, drive, dir, fname, extB);
result = lstrcmpiW(extA, extB);
}
@ -819,7 +819,7 @@ void WCMD_directory (WCHAR *args)
thisEntry->next = NULL;
/* Split into components */
WCMD_splitpath(path, drive, dir, fname, ext);
_wsplitpath(path, drive, dir, fname, ext);
WINE_TRACE("Path Parts: drive: '%s' dir: '%s' name: '%s' ext:'%s'\n",
wine_dbgstr_w(drive), wine_dbgstr_w(dir),
wine_dbgstr_w(fname), wine_dbgstr_w(ext));

View File

@ -117,7 +117,6 @@ WCHAR *WCMD_skip_leading_spaces (WCHAR *string);
BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute);
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
WCHAR *WCMD_strip_quotes(WCHAR *cmd);
WCHAR *WCMD_LoadMessage(UINT id);
void WCMD_strsubstW(WCHAR *start, const WCHAR* next, const WCHAR* insert, int len);