| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | 
							- /************************************************************************/
 
- /*  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 BOOL iscorrectext(IN const TString &fext, OUT TString* lpMistakenExt = NULL);
 
- 	// lowercase和uppercase在多字节下生僻字会出问题(珺、琤,珺转小写会变成琤,反过来琤转大写会变成珺);已修改;
 
- 	static TString lowercase(IN const TString &Str);
 
- 	static void lowercase(IN TString& str);
 
- 	static TString uppercase(IN const TString &Str);
 
- 	static void uppercase(IN TString& str);
 
- 	//static int match(IN CONST TString &sExt, IN CONST TString &sFile);
 
- 	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);
 
- 	void groupExt();
 
- 	void groupExt( IN CONST TString &exts, IN STR_VEC &vtExts );
 
- 	inline INT checklimit() { return m_pvtfiles->size() == getlimit(); }
 
- 	BOOL IsaDirectory(CONST TString &sDirectory) { return (FILE_ATTRIBUTE_DIRECTORY == GetFileAttributes(sDirectory.c_str())); }
 
- public:
 
- 	// 查找所有文件,包括子文件夹名、文件名、文件路径;
 
- 	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);
 
- 	// 查找文件名称,以及查找子目录的文件名称,但不获取子目录名(返回的文件包含扩展名)(测试ok);
 
- 	void findnames_findin_subfolder(IN CONST TString& folder);
 
- 	// 查找文件名称,不查找子目录的文件(返回的文件包含扩展名)(测试ok);
 
- 	void findnames_findout_subfolder(IN CONST TString& folder);
 
- 	// 查找文件名称,以及查找子目录的文件名称,同时获取子目录名(返回的文件包含扩展名)(测试ok);
 
- 	void findnames_within_subfolder(IN CONST TString& folder);
 
- 	// 查找文件路径和文件名,以及查找子目录的文件路径和文件名,但不获取子目录名;(返回的文件包含扩展名)(测试ok);
 
- 	void findfilesnames_findin_subfolder(IN CONST TString& folder);
 
- 	// 查找文件路径和文件名,不查找子目录;(返回的文件包含扩展名)(测试ok);
 
- 	void findfilesnames_findout_subfolder(IN CONST TString& folder);
 
- 	// 查找文件路径和文件名,以及查找子目录的文件路径和文件名,且获取子目录名;(返回的文件包含扩展名)(测试ok);
 
- 	void findfilesnames_within_subfolder(IN CONST TString& folder);
 
- };
 
- #endif
 
 
  |