From 11b07b60adc6855b399e5bdefc5da7617755e848 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Thu, 16 Sep 1999 01:36:20 +0000 Subject: [PATCH] Fix asserts on startup when profile directory is specified, but doesn't really exist. --- rdf/datasource/src/nsLocalStore.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/rdf/datasource/src/nsLocalStore.cpp b/rdf/datasource/src/nsLocalStore.cpp index 2ac4d9d4777c..d177c678e663 100644 --- a/rdf/datasource/src/nsLocalStore.cpp +++ b/rdf/datasource/src/nsLocalStore.cpp @@ -321,16 +321,30 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); rv = profile->GetCurrentProfileDir(&spec); if (NS_FAILED(rv)) return rv; + // Make sure the profile directory _really exists_ before we try + // to create file in it. + if (! spec.Exists()) + return NS_ERROR_UNEXPECTED; + spec += "localstore.rdf"; if (! spec.Exists()) { - nsOutputFileStream os(spec); - os << "" << nsEndl; - os << "" << nsEndl; - os << " " << nsEndl; - os << "" << nsEndl; + { + nsOutputFileStream os(spec); + + os << "" << nsEndl; + os << "" << nsEndl; + os << " " << nsEndl; + os << "" << nsEndl; + } + + // Okay, now see if the file exists _for real_. If it's still + // not there, it could be that the profile service gave us + // back a read-only directory. Whatever. + if (! spec.Exists()) + return NS_ERROR_UNEXPECTED; } rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,