mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 00:54:40 +00:00
Correctly expand wildcards in other directories
svn path=/trunk/; revision=4023
This commit is contained in:
parent
5dc512f7c3
commit
08a01c4da8
1 changed files with 42 additions and 3 deletions
|
@ -122,7 +122,7 @@ BOOL CheckCtrlBreak (INT mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add new entry for new argument */
|
/* add new entry for new argument */
|
||||||
static BOOL add_entry (LPINT ac, LPTSTR **arg, LPTSTR entry)
|
static BOOL add_entry (LPINT ac, LPTSTR **arg, LPCTSTR entry)
|
||||||
{
|
{
|
||||||
LPTSTR q;
|
LPTSTR q;
|
||||||
LPTSTR *oldarg;
|
LPTSTR *oldarg;
|
||||||
|
@ -149,18 +149,52 @@ static BOOL add_entry (LPINT ac, LPTSTR **arg, LPTSTR entry)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL expand (LPINT ac, LPTSTR **arg, LPTSTR pattern)
|
static BOOL expand (LPINT ac, LPTSTR **arg, LPCTSTR pattern)
|
||||||
{
|
{
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
WIN32_FIND_DATA FindData;
|
WIN32_FIND_DATA FindData;
|
||||||
BOOL ok;
|
BOOL ok;
|
||||||
|
LPCTSTR pathend;
|
||||||
|
LPTSTR dirpart, fullname;
|
||||||
|
|
||||||
|
pathend = _tcsrchr (pattern, _T('\\'));
|
||||||
|
if (NULL != pathend)
|
||||||
|
{
|
||||||
|
dirpart = malloc((pathend - pattern + 2) * sizeof(TCHAR));
|
||||||
|
if (NULL == dirpart)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
memcpy(dirpart, pattern, pathend - pattern + 1);
|
||||||
|
dirpart[pathend - pattern + 1] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dirpart = NULL;
|
||||||
|
}
|
||||||
hFind = FindFirstFile (pattern, &FindData);
|
hFind = FindFirstFile (pattern, &FindData);
|
||||||
if (INVALID_HANDLE_VALUE != hFind)
|
if (INVALID_HANDLE_VALUE != hFind)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ok = add_entry(ac, arg, FindData.cFileName);
|
if (NULL != dirpart)
|
||||||
|
{
|
||||||
|
fullname = malloc((_tcslen(dirpart) + _tcslen(FindData.cFileName) + 1) * sizeof(TCHAR));
|
||||||
|
if (NULL == fullname)
|
||||||
|
{
|
||||||
|
ok = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tcscat (_tcscpy (fullname, dirpart), FindData.cFileName);
|
||||||
|
ok = add_entry(ac, arg, fullname);
|
||||||
|
free (fullname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = add_entry(ac, arg, FindData.cFileName);
|
||||||
|
}
|
||||||
} while (FindNextFile (hFind, &FindData) && ok);
|
} while (FindNextFile (hFind, &FindData) && ok);
|
||||||
FindClose (hFind);
|
FindClose (hFind);
|
||||||
}
|
}
|
||||||
|
@ -169,6 +203,11 @@ static BOOL expand (LPINT ac, LPTSTR **arg, LPTSTR pattern)
|
||||||
ok = add_entry(ac, arg, pattern);
|
ok = add_entry(ac, arg, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL != dirpart)
|
||||||
|
{
|
||||||
|
free (dirpart);
|
||||||
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue