Handle matching of "f0_*.*" expression to "f0_000" file name in FsRtlIsNameInExpression and add relevant regression test.

svn path=/trunk/; revision=10783
This commit is contained in:
Filip Navara
2004-09-04 15:02:00 +00:00
parent 67a29489d2
commit f0120ac1d7
2 changed files with 57 additions and 16 deletions
+33 -16
View File
@@ -1,4 +1,4 @@
/* $Id: name.c,v 1.10 2004/08/18 02:32:00 navaraf Exp $
/* $Id: name.c,v 1.11 2004/09/04 15:02:00 navaraf Exp $
*
* reactos/ntoskrnl/fs/name.c
*
@@ -168,7 +168,9 @@ FsRtlDoesNameContainWildCards (IN PUNICODE_STRING Name)
* RETURN VALUE
*
* NOTE
* From Bo Branten's ntifs.h v12.
* From Bo Branten's ntifs.h v12. This function should be rewritten
* to avoid recursion and better wildcard handling should be
* implemented (see FsRtlDoesNameContainWildCards).
*
* @implemented
*/
@@ -212,22 +214,37 @@ FsRtlIsNameInExpression (IN PUNICODE_STRING Expression,
NamePosition++;
}
}
/* FIXME: Take UpcaseTable into account! */
if (Expression->Buffer[ExpressionPosition] == L'?' ||
(IgnoreCase &&
RtlUpcaseUnicodeChar(Expression->Buffer[ExpressionPosition]) ==
RtlUpcaseUnicodeChar(Name->Buffer[NamePosition])) ||
(!IgnoreCase &&
Expression->Buffer[ExpressionPosition] ==
Name->Buffer[NamePosition]))
{
NamePosition++;
ExpressionPosition++;
}
else
{
return FALSE;
/* FIXME: Take UpcaseTable into account! */
if (Expression->Buffer[ExpressionPosition] == L'?' ||
(IgnoreCase &&
RtlUpcaseUnicodeChar(Expression->Buffer[ExpressionPosition]) ==
RtlUpcaseUnicodeChar(Name->Buffer[NamePosition])) ||
(!IgnoreCase &&
Expression->Buffer[ExpressionPosition] ==
Name->Buffer[NamePosition]))
{
NamePosition++;
ExpressionPosition++;
}
else
{
return FALSE;
}
}
}
/* Handle matching of "f0_*.*" expression to "f0_000" file name. */
if (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) &&
Expression->Buffer[ExpressionPosition] == L'.')
{
while (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) &&
(Expression->Buffer[ExpressionPosition] == L'.' ||
Expression->Buffer[ExpressionPosition] == L'*' ||
Expression->Buffer[ExpressionPosition] == L'?'))
{
ExpressionPosition++;
}
}
+24
View File
@@ -0,0 +1,24 @@
#include <ddk/ntddk.h>
#include <ddk/ntifs.h>
#include <windows.h>
#include "regtests.h"
static int
RunTest(char *Buffer)
{
UNICODE_STRING Expression, Name;
RtlInitUnicodeString(&Expression, L"f0_*.*");
RtlInitUnicodeString(&Name, L"F0_000");
FAIL_IF_FALSE(FsRtlDoesNameContainWildCards(&Expression),
"FsRtlDoesNameContainWildCards didn't recognize valid expression");
FAIL_IF_FALSE(FsRtlIsNameInExpression(&Expression, &Name, TRUE, NULL),
"FsRtlIsNameInExpression failed to recognize valid match");
FAIL_IF_TRUE(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL),
"FsRtlIsNameInExpression fails to enforce case sensitivity rules");
return TS_OK;
}
DISPATCHER(Fs_1Test, "Kernel File System Runtime Library API")