#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <vector>
#include <string>
#include <stack>
using namespace std;
typedef std::vector<std::string> filePathArr;
enum EnumFileType
{
EnumFileType_File,
EnumFileType_Directory
};
#define MATCH_CHAR(c1,c2,ignore_case) ( (c1==c2) || ((ignore_case) &&(tolower(c1)==tolower(c2))) )
//EnumWildCharMatch通配匹配函数来自于:http://blog.youkuaiyun.com/c80486/article/details/6584769
//感谢作者让我方便不少,谢谢
bool EnumWildCharMatch(const char *src, const char *pattern, bool ignore_case)
{
bool result = false;
while (*src)
{
if (*pattern == '*')
{
/* 如果 pattern 的当前字符是 '*' */
/* 如果后续有多个 '*', 跳过 */
while ((*pattern == '*') || (*pattern == '?'))
pattern++;
/* 如果 '*" 后没有字符了,则正确匹配 */
if (!*pattern) return true;
/* 在 src 中查找一个与 pattern中'*"后的一个字符相同的字符*/
while (*src && (!MATCH_C
linux c++带通配找文件 枚举文件 目录
最新推荐文章于 2022-10-16 21:41:49 发布