mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:45:40 +00:00
Handle \path\ending\in\slash\ directory searches
svn path=/trunk/; revision=6942
This commit is contained in:
parent
2f434abd37
commit
2989352879
1 changed files with 71 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: find.c,v 1.40 2003/11/17 02:12:50 hyperion Exp $
|
/* $Id: find.c,v 1.41 2003/12/09 23:37:59 gvg Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -96,6 +96,7 @@ InternalFindFirstFile (
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PWSTR e1, e2;
|
PWSTR e1, e2;
|
||||||
WCHAR CurrentDir[256];
|
WCHAR CurrentDir[256];
|
||||||
|
PWCHAR SlashlessFileName;
|
||||||
PWSTR SearchPath;
|
PWSTR SearchPath;
|
||||||
PWCHAR SearchPattern;
|
PWCHAR SearchPattern;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
|
@ -104,6 +105,26 @@ InternalFindFirstFile (
|
||||||
DPRINT("FindFirstFileW(lpFileName %S)\n",
|
DPRINT("FindFirstFileW(lpFileName %S)\n",
|
||||||
lpFileName);
|
lpFileName);
|
||||||
|
|
||||||
|
Length = wcslen(lpFileName);
|
||||||
|
if (L'\\' == lpFileName[Length - 1])
|
||||||
|
{
|
||||||
|
SlashlessFileName = RtlAllocateHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
Length * sizeof(WCHAR));
|
||||||
|
if (NULL == SlashlessFileName)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memcpy(SlashlessFileName, lpFileName, (Length - 1) * sizeof(WCHAR));
|
||||||
|
SlashlessFileName[Length - 1] = L'\0';
|
||||||
|
lpFileName = SlashlessFileName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SlashlessFileName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
e1 = wcsrchr(lpFileName, L'/');
|
e1 = wcsrchr(lpFileName, L'/');
|
||||||
e2 = wcsrchr(lpFileName, L'\\');
|
e2 = wcsrchr(lpFileName, L'\\');
|
||||||
SearchPattern = max(e1, e2);
|
SearchPattern = max(e1, e2);
|
||||||
|
@ -116,6 +137,12 @@ InternalFindFirstFile (
|
||||||
Length = GetCurrentDirectoryW(sizeof(CurrentDir) / sizeof(WCHAR), SearchPath);
|
Length = GetCurrentDirectoryW(sizeof(CurrentDir) / sizeof(WCHAR), SearchPath);
|
||||||
if (0 == Length)
|
if (0 == Length)
|
||||||
{
|
{
|
||||||
|
if (NULL != SlashlessFileName)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (Length > sizeof(CurrentDir) / sizeof(WCHAR))
|
if (Length > sizeof(CurrentDir) / sizeof(WCHAR))
|
||||||
|
@ -125,6 +152,12 @@ InternalFindFirstFile (
|
||||||
Length * sizeof(WCHAR));
|
Length * sizeof(WCHAR));
|
||||||
if (NULL == SearchPath)
|
if (NULL == SearchPath)
|
||||||
{
|
{
|
||||||
|
if (NULL != SlashlessFileName)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -143,6 +176,12 @@ InternalFindFirstFile (
|
||||||
(Length + 1) * sizeof(WCHAR));
|
(Length + 1) * sizeof(WCHAR));
|
||||||
if (NULL == SearchPath)
|
if (NULL == SearchPath)
|
||||||
{
|
{
|
||||||
|
if (NULL != SlashlessFileName)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +202,12 @@ InternalFindFirstFile (
|
||||||
}
|
}
|
||||||
if (FALSE == bResult)
|
if (FALSE == bResult)
|
||||||
{
|
{
|
||||||
|
if (NULL != SlashlessFileName)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +221,12 @@ InternalFindFirstFile (
|
||||||
RtlFreeHeap (hProcessHeap,
|
RtlFreeHeap (hProcessHeap,
|
||||||
0,
|
0,
|
||||||
NtPathU.Buffer);
|
NtPathU.Buffer);
|
||||||
|
if (NULL != SlashlessFileName)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -212,9 +263,15 @@ InternalFindFirstFile (
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
RtlFreeHeap (hProcessHeap, 0, IData);
|
RtlFreeHeap (hProcessHeap, 0, IData);
|
||||||
SetLastErrorByStatus (Status);
|
if (NULL != SlashlessFileName)
|
||||||
return(NULL);
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
|
SetLastErrorByStatus (Status);
|
||||||
|
return(NULL);
|
||||||
}
|
}
|
||||||
IData->pFileInfo = (PVOID)IData + sizeof(KERNEL32_FIND_FILE_DATA);
|
IData->pFileInfo = (PVOID)IData + sizeof(KERNEL32_FIND_FILE_DATA);
|
||||||
IData->pFileInfo->FileIndex = 0;
|
IData->pFileInfo->FileIndex = 0;
|
||||||
|
@ -230,12 +287,18 @@ InternalFindFirstFile (
|
||||||
TRUE,
|
TRUE,
|
||||||
&PatternStr,
|
&PatternStr,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
if (NULL != SlashlessFileName)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(hProcessHeap,
|
||||||
|
0,
|
||||||
|
SlashlessFileName);
|
||||||
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Status %lx\n", Status);
|
DPRINT("Status %lx\n", Status);
|
||||||
RtlFreeHeap (hProcessHeap, 0, IData);
|
RtlFreeHeap (hProcessHeap, 0, IData);
|
||||||
SetLastErrorByStatus (Status);
|
SetLastErrorByStatus (Status);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
DPRINT("Found %.*S\n",IData->pFileInfo->FileNameLength/sizeof(WCHAR), IData->pFileInfo->FileName);
|
DPRINT("Found %.*S\n",IData->pFileInfo->FileNameLength/sizeof(WCHAR), IData->pFileInfo->FileName);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue