From 02d5cf287fd41512c5cc78a5cbfaefd65f9bdb0e Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Wed, 12 Sep 2007 17:41:22 +0000 Subject: [PATCH] Duh. Write them to the correct place, as well. git-svn-id: svn://10.0.0.236/trunk@235567 18797224-902f-48f8-a5cc-f745e15eee43 --- .../suite/browser/src/nsBookmarksService.cpp | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/mozilla/suite/browser/src/nsBookmarksService.cpp b/mozilla/suite/browser/src/nsBookmarksService.cpp index 105761a3379..be24f6f411f 100644 --- a/mozilla/suite/browser/src/nsBookmarksService.cpp +++ b/mozilla/suite/browser/src/nsBookmarksService.cpp @@ -1663,14 +1663,35 @@ nsBookmarksService::ReadBookmarks() nsresult nsBookmarksService::WriteBookmarks(nsIRDFDataSource *ds, nsIRDFResource *root) { - nsSpecialSystemDirectory bookmarksFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); + nsresult rv; - // XXX we should get this from prefs. - bookmarksFile += "res"; - bookmarksFile += "samples"; - bookmarksFile += "bookmarks.html"; + // Look for bookmarks.html in the current profile + // directory. This is as convoluted as it seems because we + // want to 1) not break viewer (which has no profiles), and 2) + // still deal reasonably (in the short term) when no + // bookmarks.html is installed in the profile directory. + nsFileSpec bookmarksFile; + do { + NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv); + if (NS_FAILED(rv)) break; - nsresult rv = NS_ERROR_FAILURE; + rv = profile->GetCurrentProfileDir(&bookmarksFile); + if (NS_FAILED(rv)) break; + + bookmarksFile += "bookmarks.html"; + + if (! bookmarksFile.Exists()) + rv = NS_ERROR_FAILURE; + } while (0); + + if (NS_FAILED(rv)) { + bookmarksFile = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); + bookmarksFile += "res"; + bookmarksFile += "samples"; + bookmarksFile += "bookmarks.html"; + } + + rv = NS_ERROR_FAILURE; nsOutputFileStream strm(bookmarksFile); if (strm.is_open()) {