Exemplo n.º 1
0
int SearchDirectory(vector<string> &refvecFiles, const char* cDir, const char* cExt, bool bSubdirs)
{
	WDL_DirScan ds;
	int iRet = ds.First(cDir);
	int found = 0;
	g_bAbortScan = false;
	if (!iRet)
	{
		do
		{
			if (strcmp(ds.GetCurrentFN(), ".") == 0 || strcmp(ds.GetCurrentFN(), "..") == 0)
				continue;
			WDL_String foundFile;
			ds.GetCurrentFullFN(&foundFile);
			lstrcpyn(g_CurrentScanFile, foundFile.Get(), 1024);
			if (bSubdirs && ds.GetCurrentIsDirectory())
			{
				found += SearchDirectory(refvecFiles, foundFile.Get(), cExt, true);
			}
			else
			{
				char* cFoundExt  = strrchr(foundFile.Get(), '.');
				if (cFoundExt)
				{
					cFoundExt++;
					if ((!cExt && IsMediaExtension(cFoundExt, false)) || (cExt && _stricmp(cFoundExt, cExt) == 0))
					{
						refvecFiles.push_back(foundFile.Get());
						found++;
					}
				}
			}
		}
		while(!ds.Next() && !g_bAbortScan);
	}
	return found;
}