1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef __FFSCOEX_H__
- //#if !defined(__FFSCOEX_H__)
- #define __FFSCOEX_H__
- #ifndef WIN32
- #error now only for WIN32(platform).
- #endif
- //#include <iostream>
- //#include <algorithm>
- #include <string>
- #include <vector>
- #include <sstream>
- using namespace std;
- #pragma warning(disable:4786)
- namespace helper_coffs
- {
- typedef struct SFileInfo : public WIN32_FIND_DATA
- {
- string strRootDir; //主目录,如:\\127.0.0.1\客户原片(管理软件)$
- string strChildDir; //子目录,如:1234.ly.com\\20151010-001\\新生儿
- string strAllPath; //全路径,如:\\127.0.0.1\客户原片(管理软件)$\1234.ly.com\\20151010-001\\新生儿\001.jpg
- }SFILEINFO, *LPSFILEINFO;
- const int max_limit = 0x100000; //--1048576
- const int def_limit = 0x10000; //--65536
-
- const char c_pathSeparator = '\\';
- const string s_pathSeparator = "\\";
-
- //--find files collection
- class ffscoex
- {
- public:
- typedef vector<LPSFILEINFO> typeT;
- public:
- ffscoex();
- virtual ~ffscoex();
- virtual int match(IN string fext_, IN string file_); //--文件匹配检测
-
- int find(IN string path_, IN string fext_ = "");
-
- LPSFILEINFO get(IN int i = 0) { return _co.at(i); }
- int count() { return _co.size(); }
- typeT& co() { return _co; }
- typeT& co_dir() { return _co_dir; }
- typeT& co_file() { return _co_file; }
- int limit() { return _limit; }
- void limit(IN int limit_); //--设置结果文件数目上限
-
- int dirs() { return _dirs; } //get
- void dirs(IN int dirs) { _dirs = dirs; } //--set 1:查找子目录; 0:不查找子目录
- int dir(IN string& s); //--判断s是否为目录
- int deldir(IN LPCTSTR lpDir);
- void Clear();
- private:
- inline string _uppercase_(IN string& s); //--转换s到大写字母
- void recursivefind(IN const string& root_, IN string path_, IN string fext_);
- private:
- int _limit; //--limit
- int _dirs; //--dirs-是否查找子目录(默认0-不查找)
- string _strroot; //find函数传入的目录路径为根目录
- typeT _co_file;
- typeT _co_dir;
- typeT _co;
- };
- }; //--namespace helper_coffs
- #endif //--__FFSCO__
|