} else if (spec.IsDirectory()) { name = NS_ConvertUTF8toUCS2(spec.GetLeafName());
if (NS_OK != rv) { name = NS_ConvertUTF8toUCS2(spec.GetLeafName()); rv = NS_OK; }
FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult){	nsresult		rv;	const char		*uri = nsnull;	rv = source->GetValueConst(&uri);	if (NS_FAILED(rv)) return(rv);	if (!uri)	return(NS_ERROR_UNEXPECTED);    nsCOMPtr<nsIURI>    aIURI;    if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(aIURI), uri)))        return(rv);    nsCOMPtr<nsIFileURL>    fileURL = do_QueryInterface(aIURI);    if (!fileURL)   return(PR_FALSE);	nsCOMPtr<nsIFile>	aFile;    if (NS_FAILED(rv = fileURL->GetFile(getter_AddRefs(aFile))))		return(rv);	if (!aFile)		return(NS_ERROR_UNEXPECTED);    // ensure that we DO NOT resolve aliases    nsCOMPtr<nsILocalFile>  aFileLocal = do_QueryInterface(aFile);    if (aFileLocal)    {        aFileLocal->SetFollowLinks(PR_FALSE);    }	PRUnichar		*nameUni = nsnull;	if (NS_FAILED(rv = aFile->GetUnicodeLeafName(&nameUni)))		return(rv);	if (!nameUni)		return(NS_ERROR_UNEXPECTED);	nsAutoString		name(nameUni);	Recycle(nameUni);	nameUni = nsnull;#ifdef	XP_WIN	// special hack for IE favorites under Windows; strip off the	// trailing ".url" or ".lnk" at the end of IE favorites names	PRInt32			nameLen = name.Length();	nsAutoString		theURI; theURI.AssignWithConversion(uri);	if ((theURI.Find(ieFavoritesDir) == 0) && (nameLen > 4))	{		nsAutoString	extension;		name.Right(extension, 4);		if (extension.EqualsIgnoreCase(".url") ||		    extension.EqualsIgnoreCase(".lnk"))		{			name.Truncate(nameLen - 4);		}	}#endif#ifdef	XP_BEOS	// under BEOS, try and get the "META:title" attribute (if its a file)	nsAutoString		theURI; theURI.AssignWithConversion(uri);	if (theURI.Find(netPositiveDir) == 0)	{		nsFileURL		url(uri);		nsFilePath		path(url);		nsFileSpec		spec(path);//		if (spec.IsFile() && (!spec.IsHidden()))		if (spec.IsFile())		{			const char	*nativeURI = spec.GetNativePathCString();			if (nativeURI)			{				BFile	bf(nativeURI, B_READ_ONLY);				if (bf.InitCheck() == B_OK)				{					char		beNameAttr[4096];					ssize_t		len;					if ((len = bf.ReadAttr("META:title", B_STRING_TYPE,						0, beNameAttr, sizeof(beNameAttr)-1)) > 0)					{						beNameAttr[len] = '\0';						name = NS_ConvertUTF8toUCS2(beNameAttr);					}				}			}		}		else if (spec.IsDirectory())		{			name = NS_ConvertUTF8toUCS2(spec.GetLeafName());		}	}#endif	gRDFService->GetLiteral(name.GetUnicode(), aResult);	return NS_OK;}