Click here to Skip to main content
15,923,910 members
Home / Discussions / Article Writing
   

Article Writing

 
GeneralList files in project Pin
Vern Sauder4-Jan-00 12:12
sussVern Sauder4-Jan-00 12:12 
GeneralDatabase code Pin
shahzad11-Dec-99 5:05
shahzad11-Dec-99 5:05 
GeneralRE: Database code Pin
michaels3-Feb-00 5:00
michaels3-Feb-00 5:00 
GeneralRe: Working on it Pin
PeterK21-Apr-00 7:55
PeterK21-Apr-00 7:55 
Generalxml code generator Pin
David Hubbard10-Dec-99 5:00
David Hubbard10-Dec-99 5:00 
QuestionA extended CEdit with simple input output to replace DOS shell ? Pin
To Tran Tung10-Dec-99 4:46
To Tran Tung10-Dec-99 4:46 
Generalwildcards Pin
Rajiv Ramachandran7-Dec-99 5:52
Rajiv Ramachandran7-Dec-99 5:52 
GeneralRE: wildcards Pin
Gertjan Schuurmans9-Dec-99 2:42
Gertjan Schuurmans9-Dec-99 2:42 
Hi, this code should do the trick. It's an adapted function from SysInternals' FileMon application.

Regards,

Gertjan Schuurmans
Amsterdam

//---------------------------------------------------
// MatchWildCard
//
//Parameters
// LPCTSTR pszWildCard
// LPCTSTR pszFileName
//
//Returns
// BOOL
//
//Remarks
//
// MatchWildCard tests whether the given filename matches the wildcard. pszWildCard
// can contain * and ? special characters.
//
BOOL MatchWildCard(LPCTSTR pszWildCard, LPCTSTR pszFileName)
{
#define UpCase(ch) ((ch) >= 'a' && (ch) <= 'z' ? (ch) - 'a' + 'A' : (ch))
TCHAR chFile, chWild;

// End of pattern?
if (!*pszWildCard)
{
return FALSE;
}

// If we hit a wild card, do recursion
if (*pszWildCard == '*')
{
pszWildCard++;
while (*pszFileName && *pszWildCard)
{
chFile = UpCase(*pszFileName);
chWild = UpCase(*pszWildCard);

// See if this substring matches
if (chWild == chFile || chFile == '*')
{
if (MatchWildCard(pszWildCard + 1, pszFileName + 1))
{
return TRUE;
}
}

// Try the next substring
pszFileName++;
}

// See if match condition was met
return (*pszWildCard == 0 || *pszWildCard == '*');
}

// Do straight compare until we hit a wild card
while (*pszFileName && *pszWildCard != '*')
{
chFile = UpCase(*pszFileName);
chWild = UpCase(*pszWildCard);
if (chWild == chFile || chWild == '?')
{
pszWildCard++;
pszFileName++;
} else
{
return FALSE;
}
}

// If not done, recurse
if (*pszFileName)
{
return MatchWildCard(pszWildCard, pszFileName);
}

// Make sure its a match
return (*WildCard == 0 || *WildCard == '*');

==================
The original message was:

Hi all,
I need an algorith to wildcard match two strings similar to what happens when you do a dir *.* - I`d require it to support both * and ? - nothing too fancy !!

Appreciate any help in this !!
Thanks in advance !!

Rajiv
GeneralCVS in VC IDE Pin
George3-Dec-99 20:24
George3-Dec-99 20:24 
GeneralRE: CVS in VC IDE Pin
Jonathan Gilligan7-Dec-99 17:12
Jonathan Gilligan7-Dec-99 17:12 
GeneralRE: RE: CVS in VC IDE Pin
George19-Dec-99 21:31
George19-Dec-99 21:31 
GeneralRE: RE: RE: CVS in VC IDE Pin
Jonathan Gilligan21-Dec-99 19:43
Jonathan Gilligan21-Dec-99 19:43 
GeneralRE: RE: RE: RE: CVS in VC IDE Pin
George21-Dec-99 20:21
suss George21-Dec-99 20:21 
GeneralDrawing text with "antialiasing" effect Pin
Viorel Bejan30-Nov-99 3:40
sussViorel Bejan30-Nov-99 3:40 
GeneralRE: Drawing text with Pin
Jesse Ezell14-Dec-99 15:00
Jesse Ezell14-Dec-99 15:00 
GeneralOwner drawn buttons on a CDialogBar Pin
Kevin Schock25-Nov-99 21:35
sussKevin Schock25-Nov-99 21:35 
General.ico from a HICON Pin
Thierry Maurel25-Nov-99 3:34
Thierry Maurel25-Nov-99 3:34 
GeneralRE: .ico from a HICON Pin
Dmitriy25-Nov-99 6:19
Dmitriy25-Nov-99 6:19 
GeneralOLE in-place server resizing Pin
Thierry Maurel24-Nov-99 0:08
Thierry Maurel24-Nov-99 0:08 
GeneralCHTMLView Subject Pin
Thierry Mathieu23-Nov-99 22:39
sussThierry Mathieu23-Nov-99 22:39 
GeneralRE: CHTMLView Subject Pin
Anonymous13-Dec-99 9:25
suss Anonymous13-Dec-99 9:25 
GeneralThe first request Pin
Chris Maunder19-Nov-99 16:52
cofounderChris Maunder19-Nov-99 16:52 
GeneralRE: The first request Pin
Anonymous21-Nov-99 14:36
suss Anonymous21-Nov-99 14:36 
GeneralRE: RE: The first request Pin
Chris Maunder22-Nov-99 19:05
cofounderChris Maunder22-Nov-99 19:05 
GeneralRE: The first request Pin
Mike Dunn25-Nov-99 6:57
Mike Dunn25-Nov-99 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.