if (NS_SUCCEEDED(rv = gRDF->GetResource(ieFavoritesURL, getter_AddRefs(ieFolder))))
rv = gRDF->GetResource(ieFavoritesURL, getter_AddRefs(ieFolder)); if (NS_SUCCEEDED(rv))
nsBookmarksService::ReadBookmarks(){	nsresult rv;	rv = gRDFC->MakeSeq(mInner, kNC_BookmarksRoot, nsnull);	NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to make NC:BookmarksRoot a sequence");	if (NS_FAILED(rv)) return rv;	nsSpecialSystemDirectory bookmarksFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);	// XXX we should get this from prefs.	bookmarksFile += "res";	bookmarksFile += "samples";	bookmarksFile += "bookmarks.html";	PRBool	foundIERoot = PR_FALSE;#ifdef	XP_WIN	nsCOMPtr<nsIRDFResource>	ieFolder;	char				*ieFavoritesURL = nsnull;#endif	{ // <-- scope the stream to get the open/close automatically.		nsInputFileStream strm(bookmarksFile);		if (! strm.is_open())		{			NS_ERROR("unable to open file");			return NS_ERROR_FAILURE;		}		BookmarkParser parser;		parser.Init(&strm, mInner);#ifdef	XP_MAC		parser.SetIEFavoritesRoot(kURINC_IEFavoritesRoot);#endif#ifdef	XP_WIN		nsSpecialSystemDirectory	ieFavoritesFile(nsSpecialSystemDirectory::Win_Favorites);		nsFileURL			ieFavoritesURLSpec(ieFavoritesFile);		const char			*favoritesURL = ieFavoritesURLSpec.GetAsString();		if (favoritesURL)		{			ieFavoritesURL = strdup(favoritesURL);		}		parser.SetIEFavoritesRoot(ieFavoritesURL);#endif		parser.Parse(kNC_BookmarksRoot, kNC_Bookmark);		parser.ParserFoundIEFavoritesRoot(&foundIERoot);	} // <-- scope the stream to get the open/close automatically.		// look for and import any IE Favorites	nsAutoString	ieTitle("Imported IE Favorites");		// XXX localization?#ifdef	XP_MAC	nsSpecialSystemDirectory ieFavoritesFile(nsSpecialSystemDirectory::Mac_PreferencesDirectory);	ieFavoritesFile += "Explorer";	ieFavoritesFile += "Favorites.html";	nsInputFileStream	ieStream(ieFavoritesFile);	if (ieStream.is_open())	{		if (NS_SUCCEEDED(rv = gRDFC->MakeSeq(mInner, kNC_IEFavoritesRoot, nsnull)))		{			BookmarkParser parser;			parser.Init(&ieStream, mInner);			parser.Parse(kNC_IEFavoritesRoot, kNC_IEFavorite);							nsCOMPtr<nsIRDFLiteral>	ieTitleLiteral;			if (NS_SUCCEEDED(rv = gRDF->GetLiteral(ieTitle.GetUnicode(), getter_AddRefs(ieTitleLiteral))))			{				rv = mInner->Assert(kNC_IEFavoritesRoot, kNC_Name, ieTitleLiteral, PR_TRUE);			}							// if the IE Favorites root isn't somewhere in bookmarks.html, add it			if (!foundIERoot)			{				nsCOMPtr<nsIRDFContainer> bookmarksRoot;				rv = nsComponentManager::CreateInstance(kRDFContainerCID,														nsnull,														nsIRDFContainer::GetIID(),														getter_AddRefs(bookmarksRoot));				if (NS_FAILED(rv)) return rv;				rv = bookmarksRoot->Init(mInner, kNC_BookmarksRoot);				if (NS_FAILED(rv)) return rv;				rv = bookmarksRoot->AppendElement(kNC_IEFavoritesRoot);				if (NS_FAILED(rv)) return rv;			}		}	}#endif#ifdef	XP_WIN	if (NS_SUCCEEDED(rv = gRDF->GetResource(ieFavoritesURL, getter_AddRefs(ieFolder))))	{		nsCOMPtr<nsIRDFLiteral>	ieTitleLiteral;		if (NS_SUCCEEDED(rv = gRDF->GetLiteral(ieTitle.GetUnicode(), getter_AddRefs(ieTitleLiteral))))		{			rv = mInner->Assert(ieFolder, kNC_Name, ieTitleLiteral, PR_TRUE);		}		// if the IE Favorites root isn't somewhere in bookmarks.html, add it		if (!foundIERoot)		{			nsCOMPtr<nsIRDFContainer> container;			rv = nsComponentManager::CreateInstance(kRDFContainerCID,													nsnull,													nsIRDFContainer::GetIID(),													getter_AddRefs(container));			if (NS_FAILED(rv)) return rv;			rv = container->Init(mInner, kNC_BookmarksRoot);			if (NS_FAILED(rv)) return rv;			rv = container->AppendElement(ieFolder);			if (NS_FAILED(rv)) return rv;		}	}	if (ieFavoritesURL)	{		free(ieFavoritesURL);		ieFavoritesURL = nsnull;	}#endif	return NS_OK;	}