2003-07-24 20:52:58 +00:00
|
|
|
/* $Id: string.c,v 1.11 2003/07/24 20:52:58 chorns Exp $
|
1999-12-11 21:14:49 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/fs/vfat/string.c
|
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2000-02-22 02:02:08 +00:00
|
|
|
#include <ddk/ntddk.h>
|
1999-12-11 21:14:49 +00:00
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
2000-06-29 23:35:53 +00:00
|
|
|
#include <debug.h>
|
1999-12-11 21:14:49 +00:00
|
|
|
|
|
|
|
#include "vfat.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
BOOLEAN wstrcmpjoki(PWSTR s1, PWSTR s2)
|
|
|
|
/*
|
2001-03-01 13:46:22 +00:00
|
|
|
* FUNCTION: Compare two wide character strings, s2 with jokers (* or ?)
|
1999-12-11 21:14:49 +00:00
|
|
|
* return TRUE if s1 like s2
|
|
|
|
*/
|
|
|
|
{
|
2001-03-01 13:46:22 +00:00
|
|
|
while ((*s2=='*')||(*s2=='?')||(towlower(*s1)==towlower(*s2)))
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
|
|
|
if ((*s1)==0 && (*s2)==0)
|
|
|
|
return(TRUE);
|
2001-03-01 13:46:22 +00:00
|
|
|
if(*s2=='*')
|
|
|
|
{
|
|
|
|
s2++;
|
|
|
|
while (*s1)
|
|
|
|
if (wstrcmpjoki(s1,s2)) return TRUE;
|
|
|
|
else s1++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
2001-03-01 13:46:22 +00:00
|
|
|
if ((*s2)=='.')
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
2001-03-01 13:46:22 +00:00
|
|
|
for (;((*s2)=='.')||((*s2)=='*')||((*s2)=='?');s2++) {}
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
|
|
|
if ((*s1)==0 && (*s2)==0)
|
|
|
|
return(TRUE);
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2001-05-10 04:02:21 +00:00
|
|
|
PWCHAR
|
|
|
|
vfatGetNextPathElement (PWCHAR pFileName)
|
|
|
|
{
|
2001-07-05 01:51:53 +00:00
|
|
|
if (*pFileName == L'\0')
|
2001-05-10 04:02:21 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*pFileName != L'\0' && *pFileName != L'\\')
|
|
|
|
{
|
|
|
|
pFileName++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vfatWSubString (PWCHAR pTarget, const PWCHAR pSource, size_t pLength)
|
|
|
|
{
|
|
|
|
wcsncpy (pTarget, pSource, pLength);
|
|
|
|
pTarget [pLength] = L'\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
vfatIsFileNameValid (PWCHAR pFileName)
|
|
|
|
{
|
|
|
|
PWCHAR c;
|
|
|
|
|
|
|
|
c = pFileName;
|
|
|
|
while (*c != 0)
|
|
|
|
{
|
|
|
|
if (*c == L'*' || *c == L'?')
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|