nsCOMPtr<nsIRDFResource>	ieFolder;
BookmarkDataSourceImpl::ReadBookmarks(void){	nsresult rv;	NS_WITH_SERVICE(nsIRDFContainerUtils, rdfc, kRDFContainerUtilsCID, &rv);	if (NS_FAILED(rv)) return rv;	rv = rdfc->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 += "rdf";	bookmarksFile += "bookmarks.html";	PRBool	foundIERoot = PR_FALSE;	{ // <-- 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, NS_STATIC_CAST(nsIRDFDataSource *, this));	#ifdef	XP_MAC		parser.SetIEFavoritesRoot(kURINC_IEFavoritesRoot);	#endif	#ifdef	XP_WIN		nsCOMPtr<nsIRDFResource>	ieFolder;		nsSpecialSystemDirectory	ieFavoritesFile(nsSpecialSystemDirectory::Win_Favorites);		nsFileURL			ieFavoritesURLSpec(ieFavoritesFile);		const char			*ieFavoritesURL = ieFavoritesURLSpec.GetAsString();		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())	{		NS_WITH_SERVICE(nsIRDFContainerUtils, rdfc, kRDFContainerUtilsCID, &rv);		if (NS_SUCCEEDED(rv))		{			if (NS_SUCCEEDED(rv = rdfc->MakeSeq(mInner, kNC_IEFavoritesRoot, nsnull)))			{				BookmarkParser parser;				parser.Init(&ieStream, this);				parser.Parse(kNC_IEFavoritesRoot, kNC_IEFavorite);								nsCOMPtr<nsIRDFLiteral>	ieTitleLiteral;				if (NS_SUCCEEDED(rv = gRDFService->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 = NS_NewRDFContainer(mInner, kNC_BookmarksRoot, getter_AddRefs(bookmarksRoot));					if (NS_SUCCEEDED(rv))					{						rv = bookmarksRoot->AppendElement(kNC_IEFavoritesRoot);					}				}			}		}	}#endif#ifdef	XP_WIN	if (NS_SUCCEEDED(rv = gRDFService->GetResource(ieFavoritesURL, getter_AddRefs(ieFolder))))	{		nsCOMPtr<nsIRDFLiteral>	ieTitleLiteral;		if (NS_SUCCEEDED(rv = gRDFService->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 = NS_NewRDFContainer(mInner, kNC_BookmarksRoot, getter_AddRefs(container));			if (NS_SUCCEEDED(rv))			{				rv = container->AppendElement(ieFolder);			}		}	}#endif	return NS_OK;	}