1、简介 文件查找在很多场合会被派上用场,类ffsco将文件查找操作简单封装,使用只需要传递参数查找路径和文件匹配格式(可以继承该类的 match 方法实现自己的匹配算法)到find方法,查询结果(文件/目录等)被保存到类内部的vector容器,以后想怎么用都行。 要求: 系统支持标准 C++/vector/string 使用者了解 vector/string 2、说明 使用WIN32提供的函数FindFirstFile/FindNextFile实现。子目录查找用递归方法。 3、使用方法 将文件ffsco.h/ffsco.cpp加入,在使用的地方包含文件ffsco.h,e.g. #include 'ffsco.h' 加入名字空间使用声明: using namespace helper_coffs; 定义ffsco类对象: ffsco o; 设置是否查找子目录: //o.dirs(1); //--查找子目录 设置查找结果个数上限(默认65536/最大1048576当然可以自己修改限制): //o.limit(100); //--最多查找100个 开始查找(返回结果个数): int count = o.find(path, fext); //int count = o.find('c:winnt'); //int count = o.find('c:winnt', '*.exe; *.dll; *.ini'); //int count = o.find('c:winnt', '*.exe; *.dll; *.ini'); 取结果: ffsco::typeT coo; coo = o.co(); //--文件目录混合 coo = o.co_dir(); //--全部目录 coo = o.co_file(); //--全部文件 使用结果: for (ffsco::typeT::iterator it = coo.begin(); coo.end() != it; it ++) { cout << *it << endl; //想怎么用??? } 就是这么简单:) 更多使用请参考ffsco类提供的test()... 4、演示程序 test/简单使用 test2/演示程序 演示程序效果如上图 5、结束语 ... |