1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531 |
- #include "StdAfx.h"
- #include "findfile2.h"
- // 查找文件的最大数量限制在nMaxLimit;
- CONST UINT64 nMaxLimit = 0x100000; //--1048576
- // 查找文件的默认数量限制在nDefLimit;
- CONST UINT64 nDefLimit = 0x10000; //--65536
- // 正确的扩展名及格式样列;
- // 这个值最好可以从配置文件ini或xml中获取,不用在代码里写死;
- CONST CString g_strCorrectExt = _T("*.jpg|*.jpeg|*.png|*.bmp|*.cr2|*.nef|*.raw");
- findfile2::findfile2(void)
- {
- m_nlimit = nDefLimit;
- m_pfiles = NULL;
- m_pnames = NULL;
- m_pfolders = NULL;
- m_pnames_noext = NULL;
- m_pvtfiles_sth = NULL;
- m_pvtfiles_mth = NULL;
- groupExt();
- }
- findfile2::~findfile2(void)
- {
- }
- void findfile2::groupExt()
- {
- // 将所有扩展名解析到数组里;
- INT nIndex = 0;
- CString strtmp;
- CString strEffctExt = g_strCorrectExt;
- strEffctExt += _T("|");
- do
- {
- nIndex = strEffctExt.Find(_T('|'));
- if (nIndex != -1)
- {
- strtmp = strEffctExt.Left(nIndex);
- strEffctExt = strEffctExt.Mid(nIndex + 1);
- if (strtmp != _T("*.*"))
- m_vtEffctExt.Add(strtmp.Mid(1));
- }
- } while (strEffctExt.Find(_T('|')) != -1);
- }
- void findfile2::groupExt( IN CONST CString &strExts, IN CStringArray &AryExts )
- {
- // 将所有扩展名解析到数组里;
- INT nIndex = 0;
- CString strtmp;
- CString strEffctExt = strExts;
- strEffctExt += _T("|");
- do
- {
- nIndex = strEffctExt.Find(_T('|'));
- if (nIndex != -1)
- {
- strtmp = strEffctExt.Left(nIndex);
- strEffctExt = strEffctExt.Mid(nIndex + 1);
- if (strtmp != _T("*.*"))
- AryExts.Add(strtmp);
- }
- } while (strEffctExt.Find(_T('|')) != -1);
- }
- /************************************************************************/
- /*
- 函数:iscorrectext
- 描述:判断指定的后缀串是否有效;
- 参数:
- IN: fext 输入的扩展名:
- fext的格式必须是:_T("*.jpg|*.jpeg|*.png|*.bmp")
- IN lpMistakenExt 不符合要求的扩展名;
- 返回:如果指定的扩展名符合要求,则返回TRUE,否则返回FALSE;
- 注意:
- 1.如果传入的扩展名包含_T("*.*"),则返回TRUE;若lpMistakenExt指针有效,记录第一次返回不符合要求的扩展名;
- 2.fext的格式必须是:_T("*.jpg|*.jpeg|*.png|*.bmp")
- */
- /************************************************************************/
- BOOL findfile2::iscorrectext(IN const CString &fext, OUT CString* lpMistakenExt /*= NULL*/)
- {
- if (fext.IsEmpty()) return FALSE;
- if (fext.Find(_T("*.*")) != -1) return TRUE;
- CString ext = fext;
- ext.MakeLower();
- if (ext[ext.GetLength() - 1] != _T('|'))
- ext += _T("|");
- BOOL bret = TRUE;
- int nIndex = 0;
- do
- {
- nIndex = ext.Find(_T('|'));
- if (nIndex != -1)
- {
- if (g_strCorrectExt.Find(ext.Left(nIndex)) == -1)
- {
- if (lpMistakenExt)
- *lpMistakenExt = ext.Left(nIndex);
- bret = FALSE;
- break;
- }
- ext = ext.Mid(nIndex + 1);
- }
- } while (ext.Find(_T('|')) != -1);
- return bret;
- }
- /************************************************************************/
- /*
- 函数:match
- 描述:判断指定的文件命名是否匹配指定的扩展名;
- 参数:
- IN sFileExt 扩展名;
- IN sFile 文件名;
- 返回:匹配返回非0值,否则返回0;
- 注意:
- */
- /************************************************************************/
- int findfile2::match(IN CONST CString &sFileExt, IN CONST CString &sFile)
- {
- CString fext = sFileExt;
- CString file = sFile;
- fext.MakeLower();
- file.MakeLower();
- int pos = file.ReverseFind(_T('.'));
- if (-1 != pos)
- file = file.Mid(pos);
- return (-1 != fext.Find(file));
- }
- void findfile2::setlimit(IN CONST INT &nLimit)
- {
- if (nLimit < 1)
- m_nlimit = nDefLimit;
- if (nLimit < nMaxLimit)
- m_nlimit = nLimit;
- }
- // 保留指定的扩展名文件;
- void findfile2::keepdownext(IN CONST CString &keepExt, IN CStringArray &vtfiles)
- {
- if (keepExt.Find(_T("*.*")) != -1) return;
- if (!iscorrectext(keepExt) || vtfiles.GetSize() == 0) return;
- // 获取复制扩展名;
- int nIndex = 0;
- CString strtmp;
- CString strRemainExt(keepExt);
- strRemainExt += _T("|");
- CStringArray vtRemainExt;
- // 将所有扩展名解析到数组里;
- do
- {
- nIndex = strRemainExt.Find(_T('|'));
- if (nIndex != -1)
- {
- strtmp = strRemainExt.Left(nIndex);
- strRemainExt = strRemainExt.Mid(nIndex + 1);
- if (strtmp == _T("*.*"))
- vtRemainExt.Add(strtmp);
- }
- } while (strRemainExt.Find(_T('|')) != -1);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- INT nSize = vtfiles.GetSize();
- for (int i = nSize; i > 0; i--)
- {
- BOOL bExsit = FALSE;
- for (int n = 0; n < vtRemainExt.GetSize(); n++ )
- {
- if (match(vtRemainExt.ElementAt(n), vtfiles.ElementAt(i))) {
- bExsit = TRUE;
- break;
- }
- }
- if (!bExsit) {
- vtfiles.RemoveAt(i);
- continue;
- }
- }
- }
- // 移除指定扩展名的文件;
- void findfile2::keepoutext(IN CONST CString &removeext, IN CStringArray &vtfiles)
- {
- if (removeext.Find(_T("*.*")) != -1) return;
- if (!iscorrectext(removeext) || vtfiles.GetSize() == 0) return;
- // 获取复制扩展名;
- int nIndex = 0;
- CString strtmp;
- CString strRemoveExt(removeext);
- strRemoveExt += _T("|");
- CStringArray vtRemoveExt;
- // 将所有扩展名解析到数组里;
- do
- {
- nIndex = strRemoveExt.Find(_T('|'));
- if (nIndex != -1)
- {
- strtmp = strRemoveExt.Left(nIndex);
- strRemoveExt = strRemoveExt.Mid(nIndex + 1);
- if (strtmp == _T("*.*"))
- vtRemoveExt.Add(strtmp);
- }
- } while (strRemoveExt.Find(_T('|')) != -1);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- INT nSize = vtfiles.GetSize();
- for ( int i = nSize; i > 0; i-- )
- {
- for (int n = 0; n < vtRemoveExt.GetSize(); n++ )
- {
- if (match(vtRemoveExt.ElementAt(n), vtfiles.ElementAt(i))) {
- vtfiles.RemoveAt(i);
- break;
- }
- }
- }
- }
- void findfile2::subgroupExt(IN CONST CString &ext1, IN CStringArray &vt1, IN CONST CString &ext2, IN CStringArray &vt2)
- {
- // if (ext1.find(_T("*.*")) != CString::npos ) return;
- // if ( !iscorrectext(ext1) || vt1.size() == 0 ) return;
- //
- // // 获取复制扩展名;
- // int nIndex = 0;
- // CString strtmp;
- // CString strExt1(ext1);
- // strExt1.append(_T("|"));
- // CStringArray vtExt1;
- //
- // // 将所有扩展名解析到数组里;
- // do
- // {
- // nIndex = strExt1.find(_T('|'));
- // if ( nIndex != CString::npos )
- // {
- // strtmp = strExt1.substr(0,nIndex);
- // strExt1 = strExt1.substr(nIndex+1);
- //
- // if(strtmp.compare(_T("*.*")))
- // vtExt1.push_back(strtmp);
- // }
- // } while ( strExt1.find(_T('|')) != CString::npos );
- }
- // 获取文件名;
- CString findfile2::getfilename(IN CONST CString &file)
- {
- CString name;
- CString strfile = file;
- int nIndex = strfile.ReverseFind(_T('\\')); // 如果file不包含 '\\' ,得不到文件名;
- if (nIndex == -1)
- {
- nIndex = strfile.ReverseFind(_T('.'));
- if (nIndex == -1)
- return _T("");
- return strfile.Left(nIndex);
- }
- name = strfile.Mid(nIndex+1);
- nIndex = name.Find(_T('.'));
- if (nIndex == -1)
- return _T("");
- return name.Left(nIndex);
- }
- // 全部;
- void findfile2::findall(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(path + fileinfo.cFileName);
- findall(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- m_pfiles->Add(path + fileinfo.cFileName);
- s = fileinfo.cFileName;
- file = s.Left(s.Find(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findsubfolder(IN CONST CString& folder)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- if (_T('.') != fileinfo.cFileName[0])// '.'和 '..'的系统文件去除;
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(path + fileinfo.cFileName);
- //findsubfolder(path+fileinfo.cFileName); // 不入子目录查找;
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findallsubfolder(IN CONST CString& folder)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- if (_T('.') != fileinfo.cFileName[0])// '.'和 '..'的系统文件去除;
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(path + fileinfo.cFileName);
- findsubfolder(path + fileinfo.cFileName); // 不入子目录查找;
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void findfile2::findfiles_findin_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfiles_findin_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pfiles->Add(path + fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_findout_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) != FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pfiles->Add(path + fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_within_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(path + fileinfo.cFileName);
- findfiles_within_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pfiles->Add(path + fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void findfile2::findnames_findin_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findnames_findin_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findnames_findout_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) != FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findnames_within_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(path + fileinfo.cFileName);
- findnames_within_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void findfile2::findnames_findin_subfolder_ex(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findnames_findin_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- s = fileinfo.cFileName;
- file = s.Left(s.ReverseFind(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findnames_findout_subfolder_ex(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) != FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- s = fileinfo.cFileName;
- file = s.Left(s.ReverseFind(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findnames_within_subfolder_ex(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(path + fileinfo.cFileName);
- findnames_within_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- s = fileinfo.cFileName;
- file = s.Left( s.ReverseFind(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void findfile2::findfilesnames_findin_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfilesnames_findin_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- m_pfiles->Add(path + fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfilesnames_findout_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) != FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- m_pfiles->Add(path + fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfilesnames_within_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(fileinfo.cFileName);
- findfilesnames_within_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pnames->Add(fileinfo.cFileName);
- m_pfiles->Add(path + fileinfo.cFileName);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfilesnames_findin_subfolder_ex(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfilesnames_findin_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pfiles->Add(path + fileinfo.cFileName);
- s = fileinfo.cFileName;
- file = s.Left( s.ReverseFind(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfilesnames_findout_subfolder_ex(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfilesnames_findout_subfolder_ex(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pfiles->Add(path + fileinfo.cFileName);
- s = fileinfo.cFileName;
- file = s.Left( s.ReverseFind(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfilesnames_within_subfolder_ex(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(fileinfo.cFileName);
- findfilesnames_within_subfolder_ex(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- m_pfiles->Add(path + fileinfo.cFileName);
- s = fileinfo.cFileName;
- file = s.Left(s.ReverseFind(_T('.')));
- m_pnames_noext->Add(file);
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- //////////////////////////////////////////////////////////////////////////
- void findfile2::findfiles_bynames_findin_subfolder(IN CONST CString& folder, IN CONST CString& findext, IN /*CONST*/ CStringArray &exts, IN CStringArray &names)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfiles_bynames_findin_subfolder(path + fileinfo.cFileName, fext, exts, names);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- bool bExist = false;
- CString str = getfilename(fileinfo.cFileName);
- for ( int i = names.GetSize() - 1; i > 0; i-- )
- {
- str.MakeLower();
- names.ElementAt(i).MakeLower();
- if ( str == names.ElementAt(i) )
- {
- bExist = true;
- names.RemoveAt(i);
- break;
- }
- }
- if (bExist)
- {
- if ( fext.IsEmpty() )
- {
- for ( int i = 0; i < m_vtEffctExt.GetSize(); i++ )
- {
- file = path + str + m_vtEffctExt.ElementAt(i);
- if ( PathFileExists(file) )
- {
- m_pfiles->Add(file);
- }
- }
- }
- else
- {
- for ( int i = 0; i < exts.GetSize(); i++ )
- {
- file = path + str + exts.ElementAt(i);
- if ( PathFileExists(file) )
- {
- m_pfiles->Add(file);
- }
- }
- }
- }
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_bynames_findout_subfolder(IN CONST CString& folder, IN CONST CString& findext, IN /*CONST*/ CStringArray &exts, IN CStringArray &names)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) != FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- bool bExist = false;
- CString str = getfilename(fileinfo.cFileName);
- for ( int i = names.GetSize() - 1; i > 0; i-- )
- {
- str.MakeLower();
- names.ElementAt(i).MakeLower();
- if ( str == names.ElementAt(i) )
- {
- bExist = true;
- names.RemoveAt(i);
- break;
- }
- }
- if (bExist)
- {
- if ( fext.IsEmpty() )
- {
- for ( int i = 0; i < m_vtEffctExt.GetSize(); i++ )
- {
- file = path + str + exts.ElementAt(i);
- if ( PathFileExists(file) )
- {
- m_pfiles->Add(file);
- }
- }
- }
- else
- {
- for ( int i = 0; i < exts.GetSize(); i++ )
- {
- file = path + str + exts.ElementAt(i);
- if ( PathFileExists(file) )
- {
- m_pfiles->Add(file);
- }
- }
- }
- }
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_bynames_within_subfolder(IN CONST CString& folder, IN CONST CString& findext, IN /*CONST*/ CStringArray &exts, IN CStringArray &names)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- m_pfolders->Add(fileinfo.cFileName);
- findfiles_bynames_within_subfolder(path + fileinfo.cFileName, fext, exts, names);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- bool bExist = false;
- CString str = getfilename(fileinfo.cFileName);
- for ( int i = names.GetSize() - 1; i > 0; i-- )
- {
- str.MakeLower();
- names.ElementAt(i).MakeLower();
- if ( str == names.ElementAt(i) )
- {
- bExist = true;
- names.RemoveAt(i);
- break;
- }
- }
- if (bExist)
- {
- if ( fext.IsEmpty() )
- {
- for ( int i = 0; i < m_vtEffctExt.GetSize(); i++ )
- {
- file = path + str + exts.ElementAt(i);
- if ( PathFileExists(file) )
- {
- m_pfiles->Add(file);
- }
- }
- }
- else
- {
- for ( int i = 0; i < exts.GetSize(); i++ )
- {
- file = path + str + exts.ElementAt(i);
- if ( PathFileExists(file) )
- {
- m_pfiles->Add(file);
- }
- }
- }
- }
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_withthumbnail_findin_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfiles_withthumbnail_findin_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- if ( fileinfo.cFileName[0] == _T('s') || fileinfo.cFileName[0] == _T('m') ||
- fileinfo.cFileName[0] == _T('S') || fileinfo.cFileName[0] == _T('M'))
- continue;
- m_pfiles->Add(path + fileinfo.cFileName);
- // 查找相应的s和m图,如果不存在,则使用""表示;
- file = path + _T("s") + fileinfo.cFileName;
- if ( PathFileExists(file) )
- {
- m_pvtfiles_sth->Add(file);
- }
- else
- {
- m_pvtfiles_sth->Add(_T(""));
- }
- file = path + _T("m") + fileinfo.cFileName;
- if ( PathFileExists(file) )
- {
- m_pvtfiles_mth->Add(file);
- }
- else
- {
- m_pvtfiles_mth->Add(_T(""));
- }
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_withthumbnail_findout_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) != FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- if ( fileinfo.cFileName[0] == _T('s') || fileinfo.cFileName[0] == _T('m') ||
- fileinfo.cFileName[0] == _T('S') || fileinfo.cFileName[0] == _T('M'))
- continue;
- m_pfiles->Add(path + fileinfo.cFileName);
- // 查找相应的s和m图,如果不存在,则使用""表示;
- file = path + _T("s") + fileinfo.cFileName;
- if ( PathFileExists(file) )
- {
- m_pvtfiles_sth->Add(file);
- }
- else
- {
- m_pvtfiles_sth->Add(_T(""));
- }
- file = path + _T("m") + fileinfo.cFileName;
- if ( PathFileExists(file) )
- {
- m_pvtfiles_mth->Add(file);
- }
- else
- {
- m_pvtfiles_mth->Add(_T(""));
- }
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
- void findfile2::findfiles_withthumbnail_within_subfolder(IN CONST CString& folder, IN CONST CString& findext)
- {
- CString path = folder;
- if (path.GetLength() > 0 && _T('\\') != path[path.GetLength() - 1])
- path += _T("\\");
- CString fext = findext;
- if (fext == _T("*") || fext == _T("*.*"))
- fext = _T("");
- CString file = _T("*");
- CString s = path + file;
- WIN32_FIND_DATA fileinfo = { 0 };
- HANDLE handle = FindFirstFile(s, &fileinfo);
- if (NULL != handle && INVALID_HANDLE_VALUE != handle)
- {
- do
- {
- // 检查是否超过最大数;
- if (checklimit()) break;
- // '.'和 '..'的系统文件去除;
- if (_T('.') != fileinfo.cFileName[0])
- {
- if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY) // 目录;
- {
- findfiles_withthumbnail_within_subfolder(path + fileinfo.cFileName, fext);
- }
- else
- {
- if (!checklimit() && (0 == fext.GetLength() || match(fext, fileinfo.cFileName)))
- {
- if ( fileinfo.cFileName[0] == _T('s') || fileinfo.cFileName[0] == _T('m') ||
- fileinfo.cFileName[0] == _T('S') || fileinfo.cFileName[0] == _T('M'))
- continue;
- m_pfiles->Add(path + fileinfo.cFileName);
- // 查找相应的s和m图,如果不存在,则使用""表示;
- file = path + _T("s") + fileinfo.cFileName;
- if ( PathFileExists(file) )
- {
- m_pvtfiles_sth->Add(file);
- }
- else
- {
- m_pvtfiles_sth->Add(_T(""));
- }
- file = path + _T("m") + fileinfo.cFileName;
- if ( PathFileExists(file) )
- {
- m_pvtfiles_mth->Add(file);
- }
- else
- {
- m_pvtfiles_mth->Add(_T(""));
- }
- }
- }
- }
- } while (FindNextFile(handle, &fileinfo));
- FindClose(handle);
- }
- }
|