1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /************************************************************************/
- /* Copyright (C), 2016-2020, [IT], 保留所有权利;
- /* 模 块 名:;
- /* 描 述:;
- /*
- /* 版 本:[V];
- /* 作 者:[IT];
- /* 日 期:[12/22/2016];
- /*
- /*
- /* 注 意:;
- /*
- /* 修改记录:[IT];
- /* 修改日期:;
- /* 修改版本:;
- /* 修改内容:;
- /************************************************************************/
- #ifndef __FIND_FILE_20151003__
- #define __FIND_FILE_20151003__
- #include <string>
- #include <vector>
- using namespace std;
- #ifndef _UNICODE
- typedef string TString;
- #else
- typedef wstring TString;
- #endif
- typedef vector<TString> STR_VEC;
- #pragma once
- class findfile
- {
- public:
- findfile(void);
- virtual ~findfile(void);
- //protected:
- public:
- INT m_nlimit;
- STR_VEC m_vtEffctExt;
- STR_VEC *m_pvtfiles;
- STR_VEC *m_pvtnames;
- STR_VEC *m_pvtfolders;
- STR_VEC *m_pvtfiles_sth; // s小图;
- STR_VEC *m_pvtfiles_mth; // m小图;
- public:
- static inline int findfile::match(IN CONST TString &strExt, IN CONST TString &strfile)
- {
- int pos = strfile.find_last_of(_T('.'));
- if (TString::npos != pos)
- return !_tcsicmp(strExt.c_str(), strfile.substr(pos).c_str());
- return FALSE;
- }
-
- static TString getfilename(IN CONST TString &file);
- protected:
- INT getlimit() const { return m_nlimit; }
- void setlimit(IN CONST INT &nlimit);
- inline INT checklimit() { return m_pvtfiles->size() == getlimit(); }
- BOOL IsaDirectory(CONST TString &sDirectory) { return (FILE_ATTRIBUTE_DIRECTORY == GetFileAttributes(sDirectory.c_str())); }
- public:
- void find1st(TString folder, TString &file);
- // 查找所有文件,包括子文件夹名、文件名、文件路径;
- void findall(IN CONST TString& folder);
- // 只返回2级子目录名(测试ok);
- void findsubfolder(IN CONST TString& folder);
- // 只返回所有子目录名(测试ok);
- void findallsubfolder(IN CONST TString& folder);
- // 查找文件路径,以及查找子目录的文件路径,但不获取子目录名(测试ok);
- void findfiles_findin_subfolder(IN CONST TString& folder);
- // 查找文件路径,不查找子目录的文件(测试ok);
- void findfiles_findout_subfolder(IN CONST TString& folder);
- // 查找文件路径,以及查找子目录的文件路径,同时获取子目录名(测试ok);
- void findfiles_within_subfolder(IN CONST TString& folder);
- };
- #endif
|