diff --git a/reactos/ntoskrnl/fs/name.c b/reactos/ntoskrnl/fs/name.c index a19afa4abd2..41d496e3a3a 100644 --- a/reactos/ntoskrnl/fs/name.c +++ b/reactos/ntoskrnl/fs/name.c @@ -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++; } } diff --git a/reactos/regtests/kmregtests/tests/fs-1.c b/reactos/regtests/kmregtests/tests/fs-1.c new file mode 100755 index 00000000000..271427bdf65 --- /dev/null +++ b/reactos/regtests/kmregtests/tests/fs-1.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#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")