I decided to write my own code to search for files and directories, make it IDE independent and add some useful features. The result of my efforts is FindFile, the details of which have been given in this article.
|
//=============================================================================
// Author: Louka Dlagnekov
// File: wildcard.cpp
// Description: This code compares a file name with a filter to determine
// whether the filter properly matches the file name.
// Some of this code is downloaded from
// http://www.1cplusplusstreet.com/ It has been extended to include
// multiple filters separated by a ';'
//
// Original copyright notice:
//**************************************
//
// Name: ^NEW^ -- wildcard string compar
// e (globbing)
// Description:matches a string against
// a wildcard string such as "*.*" or "bl?h
// .*" etc. This is good for file globbing
// or to match hostmasks.
// By: Jack Handy
//
// Returns:1 on match, 0 on no match.
//
//This code is copyrighted and has// limited warranties.Please see http://
// www.1CPlusPlusStreet.com/xq/ASP/txtCodeI
// d.1680/lngWId.3/qx/vb/scripts/ShowCode.h
// tm//for details.//**************************************
//
//=============================================================================
#include <string>
using namespace std;
class wildcard
{
private:
// check string for substring
static bool find(const char *s1,const char *s2);
// replacement for strncmp, allows for '?'
static bool wc_cmp(const char *s1,const char *s2,int len);
static bool EndCmp(char *src,const char *cmp);
static bool StartCmp(char *src,const char *cmp);
public:
// Allows multiple filters separated by ';'
static bool match (string file, string filter);
// the main wildcard compare function
static bool wildcmp(string _findstr, string _cmp);
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.