PRBool hasMore = PR_FALSE; nsCOMPtr<nsISimpleEnumerator> dirIterator; rv = searchDir->GetDirectoryEntries(getter_AddRefs(dirIterator)); if (NS_FAILED(rv)) return rv;
for (nsDirectoryIterator i(nativeDir, PR_TRUE); i.Exists(); i++) { const nsFileSpec	fileSpec = (const nsFileSpec &)i; if (fileSpec.IsHidden()) {  continue; }
InternetSearchDataSource::GetSearchEngineList(nsIFile *searchDir,              PRBool isSystemSearchFile, PRBool checkMacFileType){        nsresult			rv = NS_OK;    if (!mInner)    {    	return(NS_RDF_NO_VALUE);    }    PRBool hasMore = PR_FALSE;    nsCOMPtr<nsISimpleEnumerator> dirIterator;    rv = searchDir->GetDirectoryEntries(getter_AddRefs(dirIterator));    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIFile> dirEntry;	while ((rv = dirIterator->HasMoreElements(&hasMore)) == NS_OK && hasMore)	{		rv = dirIterator->GetNext((nsISupports**)getter_AddRefs(dirEntry));        if (NS_FAILED(rv))          continue;        // Ignore hidden files/directories        PRBool isHidden;        rv = dirEntry->IsHidden(&isHidden);        if (NS_FAILED(rv) || isHidden)          continue;        PRBool isDirectory;        rv = dirEntry->IsDirectory(&isDirectory);        if (NS_FAILED(rv))          continue;        if (isDirectory)        {          GetSearchEngineList(dirEntry, isSystemSearchFile, checkMacFileType);          continue;        }        // Skip over empty files        // Note: use GetFileSize even on Mac [instead of GetFileSizeWithResFork()]        // as we want the size of ONLY the data fork        PRInt64 fileSize;        rv = dirEntry->GetFileSize(&fileSize);        if (NS_FAILED(rv) || (fileSize == 0))            continue;            nsAutoString uri;        rv = dirEntry->GetPath(uri);        if (NS_FAILED(rv))        continue;		PRInt32		len = uri.Length();		if (len < 5)		{			continue;		}#ifdef	XP_MAC		if (checkMacFileType == PR_TRUE)		{            nsCOMPtr<nsILocalFileMac> macFile(do_QueryInterface(dirEntry));            if (!macFile)                continue;            OSType type, creator;            rv = macFile->GetFileType(&type);            if (NS_FAILED(rv) || type != 'issp')                continue;            rv = macFile->GetFileCreator(&creator);     // Do we really care about creator?              if (NS_FAILED(rv) || creator != 'fndf')                continue;  		}#endif		// check the extension (must be ".src")		nsAutoString	extension;		if ((uri.Right(extension, 4) != 4) || (!extension.EqualsIgnoreCase(".src")))		{			continue;		}		// check for various icons		PRBool		foundIconFlag = PR_FALSE;		nsFileSpec	iconSpec;		nsAutoString	temp;				nsCOMPtr<nsILocalFile> iconFile;		uri.Left(temp, uri.Length()-4);		temp.Append(NS_LITERAL_STRING(".gif"));		const	nsFileSpec	gifIconFile(temp);		if (gifIconFile.IsFile())		{			iconSpec = gifIconFile;			foundIconFlag = PR_TRUE;		}		if (foundIconFlag == PR_FALSE)		{			uri.Left(temp, uri.Length()-4);			temp.Append(NS_LITERAL_STRING(".jpg"));			const	nsFileSpec	jpgIconFile(temp);			if (jpgIconFile.IsFile())			{				iconSpec = jpgIconFile;				foundIconFlag = PR_TRUE;			}		}		if (foundIconFlag == PR_FALSE)		{			uri.Left(temp, uri.Length()-4);			temp.Append(NS_LITERAL_STRING(".jpeg"));			const	nsFileSpec	jpegIconFile(temp);			if (jpegIconFile.IsFile())			{				iconSpec = jpegIconFile;				foundIconFlag = PR_TRUE;			}		}		if (foundIconFlag == PR_FALSE)		{			uri.Left(temp, uri.Length()-4);			temp.Append(NS_LITERAL_STRING(".png"));			const	nsFileSpec	pngIconFile(temp);			if (pngIconFile.IsFile())			{				iconSpec = pngIconFile;				foundIconFlag = PR_TRUE;			}		}				if (foundIconFlag)		{		  NS_NewNativeLocalFile(nsDependentCString((const char *)iconSpec), PR_TRUE, getter_AddRefs(iconFile));		}		SaveEngineInfoIntoGraph(dirEntry, iconFile, nsnull, nsnull, isSystemSearchFile, checkMacFileType);	}		return(rv);}