зеркало из https://github.com/mozilla/gecko-dev.git
Converted use of nsIFileLocator to nsIDirectoryService
This commit is contained in:
Родитель
19a9843607
Коммит
5469d37218
|
@ -36,17 +36,12 @@
|
|||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
#include "rdf.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsIFileLocator.h"
|
||||
#include "nsFileLocations.h"
|
||||
|
||||
static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -344,22 +339,24 @@ static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
nsresult rv;
|
||||
nsFileSpec spec;
|
||||
nsCOMPtr <nsIFileSpec> localStoreSpec;
|
||||
|
||||
// Look for localstore.rdf in the current profile
|
||||
// directory. Bomb if we can't find it.
|
||||
|
||||
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
nsCOMPtr<nsIFileSpec> tempSpec;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_APP_LOCALSTORE_50_FILE, getter_AddRefs(aFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_LocalStore50, getter_AddRefs(localStoreSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = localStoreSpec->GetFileSpec(&spec);
|
||||
// Turn the nsIFile into a nsFileSpec.
|
||||
// This is evil! nsOutputFileStream needs
|
||||
// to take an nsILocalFile (bug #46394)
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = aFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsFileSpec spec((const char *)pathBuf);
|
||||
|
||||
// XXX TODO: rewrite this to use the nsIFileSpec we already have.
|
||||
if (! spec.Exists()) {
|
||||
{
|
||||
nsOutputFileStream os(spec);
|
||||
|
|
|
@ -95,7 +95,6 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsFileLocations.h"
|
||||
|
||||
#include "nsIFileLocator.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIWalletService.h"
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsISound.h"
|
||||
//#include "nsICommonDialogs.h"
|
||||
|
@ -83,9 +85,6 @@
|
|||
#include "nsIHTTPChannel.h"
|
||||
#include "nsHTTPEnums.h"
|
||||
|
||||
#include "nsIFileLocator.h"
|
||||
#include "nsFileLocations.h"
|
||||
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -117,7 +116,6 @@ static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
|
@ -4182,22 +4180,24 @@ nsBookmarksService::GetBookmarksFile(nsFileSpec* aResult)
|
|||
// 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.
|
||||
do {
|
||||
nsCOMPtr <nsIFileSpec> bookmarksFile;
|
||||
|
||||
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_BookmarksFile50, getter_AddRefs(bookmarksFile));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
rv = bookmarksFile->GetFileSpec(aResult);
|
||||
if (NS_FAILED(rv)) break;
|
||||
} while (0);
|
||||
|
||||
nsCOMPtr<nsIFile> bookmarksFile;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_BOOKMARKS_50_FILE, getter_AddRefs(bookmarksFile));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
// TODO: When the code which calls this can us nsIFIle
|
||||
// or nsILocalFile, this conversion from nsiFile to
|
||||
// nsFileSpec can go away.
|
||||
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = bookmarksFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*aResult = (const char *)pathBuf;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
*aResult = nsSpecialSystemDirectory(nsSpecialSystemDirectory::Moz_BinDirectory); // Use Moz_BinDirectory, NOT CurrentProcess
|
||||
*aResult += "chrome";
|
||||
*aResult += "bookmarks";
|
||||
*aResult += "content";
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plhash.h"
|
||||
|
@ -63,8 +64,6 @@
|
|||
#include "nsIMdbFactoryFactory.h"
|
||||
#include "mdb.h"
|
||||
|
||||
#include "nsIFileLocator.h"
|
||||
#include "nsFileLocations.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#ifdef DEBUG_sspitzer
|
||||
|
@ -78,7 +77,6 @@
|
|||
// CIDs
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
static nsresult
|
||||
|
@ -1539,16 +1537,8 @@ nsGlobalHistory::OpenDB()
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr <nsIFileSpec> historyFile;
|
||||
nsFileSpec dbfile;
|
||||
|
||||
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_History50, getter_AddRefs(historyFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = historyFile->GetFileSpec(&dbfile);
|
||||
nsCOMPtr <nsIFile> historyFile;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_HISTORY_50_FILE, getter_AddRefs(historyFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
static NS_DEFINE_CID(kMorkCID, NS_MORK_CID);
|
||||
|
@ -1575,13 +1565,21 @@ nsGlobalHistory::OpenDB()
|
|||
|
||||
nsIMdbHeap* dbHeap = 0;
|
||||
mdb_bool dbFrozen = mdbBool_kFalse; // not readonly, we want modifiable
|
||||
PRBool exists;
|
||||
|
||||
if (dbfile.Exists()) {
|
||||
nsXPIDLCString filePath;
|
||||
rv = historyFile->GetPath(getter_Copies(filePath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = historyFile->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (exists) {
|
||||
mdb_bool canopen = 0;
|
||||
mdbYarn outfmt = { nsnull, 0, 0, 0, 0, nsnull };
|
||||
|
||||
nsMdbPtr<nsIMdbFile> oldFile(mEnv); // ensures file is released
|
||||
err = factory->OpenOldFile(mEnv, dbHeap, dbfile.GetNativePathCString(),
|
||||
err = factory->OpenOldFile(mEnv, dbHeap, filePath,
|
||||
dbFrozen, getter_Acquires(oldFile));
|
||||
|
||||
if ((err != 0) || !oldFile) return NS_ERROR_FAILURE;
|
||||
|
@ -1627,7 +1625,7 @@ nsGlobalHistory::OpenDB()
|
|||
else {
|
||||
|
||||
nsMdbPtr<nsIMdbFile> newFile(mEnv); // ensures file is released
|
||||
err = factory->CreateNewFile(mEnv, dbHeap, dbfile.GetNativePathCString(),
|
||||
err = factory->CreateNewFile(mEnv, dbHeap, filePath,
|
||||
getter_Acquires(newFile));
|
||||
|
||||
if ((err != 0) || !newFile) return NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче