nsAutoString	data; rv = ReadFileContents(fileSpec, data);   if (NS_FAILED(rv))	continue;  nsCOMPtr<nsIRDFResource>	searchRes; char		*searchURI = searchURL.ToNewCString(); if (searchURI) { if (NS_SUCCEEDED(rv = gRDFService->GetResource(searchURI, getter_AddRefs(searchRes)))) {  nsAutoString	nameValue; if (NS_SUCCEEDED(rv = GetData(data, "search", "name", nameValue))) { nsCOMPtr<nsIRDFLiteral>	nameLiteral; if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(nameValue.GetUnicode(), getter_AddRefs(nameLiteral)))) { mInner->Assert(searchRes, kNC_Name, nameLiteral, PR_TRUE); } }   if (iconURL.Length() > 0) { nsCOMPtr<nsIRDFLiteral>	iconLiteral; if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(iconURL.GetUnicode(), getter_AddRefs(iconLiteral)))) { mInner->Assert(searchRes, kNC_Icon, iconLiteral, PR_TRUE); } }   mInner->Assert(kNC_SearchEngineRoot, kNC_Child, searchRes, PR_TRUE); } nsCRT::free(searchURI); searchURI = nsnull; }   } }
uri.Left(temp, uri.Length()-4); temp.AppendWithConversion(".gif"); const	nsFileSpec	gifIconFile(temp); if (gifIconFile.IsFile()) { iconSpec = gifIconFile; foundIconFlag = PR_TRUE; } if (foundIconFlag == PR_FALSE) { uri.Left(temp, uri.Length()-4); temp.AppendWithConversion(".jpg"); const	nsFileSpec	jpgIconFile(temp); if (jpgIconFile.IsFile()) { iconSpec = jpgIconFile; foundIconFlag = PR_TRUE;
InternetSearchDataSource::GetSearchEngineList(nsFileSpec nativeDir, PRBool checkMacFileType){        nsresult			rv = NS_OK;	if (!mInner)	{		return(NS_RDF_NO_VALUE);	}	for (nsDirectoryIterator i(nativeDir, PR_TRUE); i.Exists(); i++)	{		const nsFileSpec	fileSpec = (const nsFileSpec &)i;		if (fileSpec.IsHidden())		{			continue;		}		const char		*childURL = fileSpec;		if (fileSpec.IsDirectory())		{			GetSearchEngineList(fileSpec, checkMacFileType);		}		else		if (childURL != nsnull)		{			nsAutoString	uri(childURL);			PRInt32		len = uri.Length();			if (len > 4)			{				// check for various icons				nsAutoString	iconURL;				PRInt32		extensionOffset;				extensionOffset = uri.RFind(".src", PR_TRUE);				if ((extensionOffset >= 0) && (extensionOffset == uri.Length()-4))				{					nsAutoString	temp;					uri.Left(temp, uri.Length()-4);					temp += ".gif";					const	nsFileSpec	gifIconFile(temp);					if (gifIconFile.IsFile())					{						nsFileURL	gifIconFileURL(gifIconFile);						iconURL = gifIconFileURL.GetURLString();					}					uri.Left(temp, uri.Length()-4);					temp += ".jpg";					const	nsFileSpec	jpgIconFile(temp);					if (jpgIconFile.IsFile())					{						nsFileURL	jpgIconFileURL(jpgIconFile);						iconURL = jpgIconFileURL.GetURLString();					}					uri.Left(temp, uri.Length()-4);					temp += ".jpeg";					const	nsFileSpec	jpegIconFile(temp);					if (jpegIconFile.IsFile())					{						nsFileURL	jpegIconFileURL(jpegIconFile);						iconURL = jpegIconFileURL.GetURLString();					}					uri.Left(temp, uri.Length()-4);					temp += ".png";					const	nsFileSpec	pngIconFile(temp);					if (pngIconFile.IsFile())					{						nsFileURL	pngIconFileURL(pngIconFile);						iconURL = pngIconFileURL.GetURLString();					}				}#ifdef	XP_MAC				if (checkMacFileType == PR_TRUE)				{					CInfoPBRec	cInfo;					OSErr		err;					err = fileSpec.GetCatInfo(cInfo);					if ((err) || (cInfo.hFileInfo.ioFlFndrInfo.fdType != 'issp') ||						(cInfo.hFileInfo.ioFlFndrInfo.fdCreator != 'fndf'))						continue;				}#endif				// check the extension				nsAutoString	extension;				if ((uri.Right(extension, 4) == 4) && (extension.EqualsIgnoreCase(".src")))				{					char	c;#ifdef	XP_WIN					c = '\\';#elif	XP_MAC					c = ':';#else					c = '/';#endif					PRInt32	separatorOffset = uri.RFindChar(PRUnichar(c));					if (separatorOffset > 0)					{//						uri.Cut(0, separatorOffset+1);												nsAutoString	searchURL(kEngineProtocol);						char		*uriC = uri.ToNewCString();						if (!uriC)	continue;						char		*uriCescaped = nsEscape(uriC, url_Path);						nsCRT::free(uriC);						if (!uriCescaped)	continue;//						searchURL += uri;						searchURL += uriCescaped;						nsCRT::free(uriCescaped);/*						char *baseFilename = uri.ToNewCString();						if (!baseFilename)	continue;						baseFilename = nsUnescape(baseFilename);						if (!baseFilename)	continue;*/						nsAutoString	data;						rv = ReadFileContents(fileSpec, data);//						nsCRT::free(baseFilename);//						baseFilename = nsnull;						if (NS_FAILED(rv))	continue;						nsCOMPtr<nsIRDFResource>	searchRes;						char		*searchURI = searchURL.ToNewCString();						if (searchURI)						{							if (NS_SUCCEEDED(rv = gRDFService->GetResource(searchURI, getter_AddRefs(searchRes))))							{								// save name of search engine (as specified in file)								nsAutoString	nameValue;								if (NS_SUCCEEDED(rv = GetData(data, "search", "name", nameValue)))								{									nsCOMPtr<nsIRDFLiteral>	nameLiteral;									if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(nameValue.GetUnicode(),											getter_AddRefs(nameLiteral))))									{										mInner->Assert(searchRes, kNC_Name, nameLiteral, PR_TRUE);									}								}																// save icon url (if we have one)								if (iconURL.Length() > 0)								{									nsCOMPtr<nsIRDFLiteral>	iconLiteral;									if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(iconURL.GetUnicode(),											getter_AddRefs(iconLiteral))))									{										mInner->Assert(searchRes, kNC_Icon, iconLiteral, PR_TRUE);									}								}								// Note: add the child relationship last								mInner->Assert(kNC_SearchEngineRoot, kNC_Child, searchRes, PR_TRUE);							}							nsCRT::free(searchURI);							searchURI = nsnull;						}//						nsCRT::free(baseFilename);//						baseFilename = nsnull;					}				}			}		}	}	return(rv);}