reactos/reactos/drivers/fs/vfat/string.c
Hartmut Birr 62eac3dcff * Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
  vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
  this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.

svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00

97 lines
1.7 KiB
C

/* $Id: string.c,v 1.9 2002/11/11 21:49:18 hbirr Exp $
*
* 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 *****************************************************************/
#include <ddk/ntddk.h>
#include <wchar.h>
#define NDEBUG
#include <debug.h>
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
BOOLEAN wstrcmpjoki(PWSTR s1, PWSTR s2)
/*
* FUNCTION: Compare two wide character strings, s2 with jokers (* or ?)
* return TRUE if s1 like s2
*/
{
while ((*s2=='*')||(*s2=='?')||(towlower(*s1)==towlower(*s2)))
{
if ((*s1)==0 && (*s2)==0)
return(TRUE);
if(*s2=='*')
{
s2++;
while (*s1)
if (wstrcmpjoki(s1,s2)) return TRUE;
else s1++;
}
else
{
s1++;
s2++;
}
}
if ((*s2)=='.')
{
for (;((*s2)=='.')||((*s2)=='*')||((*s2)=='?');s2++) {}
}
if ((*s1)==0 && (*s2)==0)
return(TRUE);
return(FALSE);
}
PWCHAR
vfatGetNextPathElement (PWCHAR pFileName)
{
if (*pFileName == L'\0')
{
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;
}