Bug 685236 - Stop using GetNativePath in nsAppRunner.cpp. r?mossop
GetPersistentDescriptor is suitable for serialization purpose.
MozReview-Commit-ID: 5IZI843ovAv
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -15,17 +15,16 @@
#include "mozilla/MemoryChecking.h"
#include "mozilla/Poison.h"
#include "mozilla/Preferences.h"
#include "mozilla/Printf.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "mozilla/intl/LocaleService.h"
-#include "nsNativeCharsetUtils.h"
#include "nsAppRunner.h"
#include "mozilla/XREAppData.h"
#include "mozilla/Bootstrap.h"
#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID)
#include "nsUpdateDriver.h"
#endif
#include "ProfileReset.h"
@@ -2504,19 +2503,18 @@ SelectProfile(nsIProfileLock* *aResult,
rv = NS_ERROR_ABORT;
aProfileSvc->Flush();
// XXXben need to ensure prefs.js exists here so the tinderboxes will
// not go orange.
nsCOMPtr<nsIFile> prefsJSFile;
profile->GetRootDir(getter_AddRefs(prefsJSFile));
prefsJSFile->AppendNative(NS_LITERAL_CSTRING("prefs.js"));
- nsAutoCString pathStr;
- prefsJSFile->GetNativePath(pathStr);
- PR_fprintf(PR_STDERR, "Success: created profile '%s' at '%s'\n", arg, pathStr.get());
+ PR_fprintf(PR_STDERR, "Success: created profile '%s' at '%s'\n", arg,
+ prefsJSFile->DisplayPath().get());
bool exists;
prefsJSFile->Exists(&exists);
if (!exists) {
// Ignore any errors; we're about to return NS_ERROR_ABORT anyway.
Unused << prefsJSFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
}
// XXXdarin perhaps 0600 would be better?
@@ -2759,36 +2757,44 @@ CheckCompatibility(nsIFile* aProfileDir,
if (NS_FAILED(rv) || !aOSABI.Equals(buf))
return false;
rv = parser.GetString("Compatibility", "LastPlatformDir", buf);
if (NS_FAILED(rv))
return false;
nsCOMPtr<nsIFile> lf;
- rv = NS_NewNativeLocalFile(buf, false,
+ rv = NS_NewNativeLocalFile(EmptyCString(), false,
getter_AddRefs(lf));
if (NS_FAILED(rv))
return false;
+ rv = lf->SetPersistentDescriptor(buf);
+ if (NS_FAILED(rv))
+ return false;
+
bool eq;
rv = lf->Equals(aXULRunnerDir, &eq);
if (NS_FAILED(rv) || !eq)
return false;
if (aAppDir) {
rv = parser.GetString("Compatibility", "LastAppDir", buf);
if (NS_FAILED(rv))
return false;
- rv = NS_NewNativeLocalFile(buf, false,
+ rv = NS_NewNativeLocalFile(EmptyCString(), false,
getter_AddRefs(lf));
if (NS_FAILED(rv))
return false;
+ rv = lf->SetPersistentDescriptor(buf);
+ if (NS_FAILED(rv))
+ return false;
+
rv = lf->Equals(aAppDir, &eq);
if (NS_FAILED(rv) || !eq)
return false;
}
// If we see this flag, caches are invalid.
rv = parser.GetString("Compatibility", "InvalidateCaches", buf);
*aCachesOK = (NS_FAILED(rv) || !buf.EqualsLiteral("1"));
@@ -2818,21 +2824,21 @@ WriteVersion(nsIFile* aProfileDir, const
{
nsCOMPtr<nsIFile> file;
aProfileDir->Clone(getter_AddRefs(file));
if (!file)
return;
file->AppendNative(FILE_COMPATIBILITY_INFO);
nsAutoCString platformDir;
- aXULRunnerDir->GetNativePath(platformDir);
+ Unused << aXULRunnerDir->GetPersistentDescriptor(platformDir);
nsAutoCString appDir;
if (aAppDir)
- aAppDir->GetNativePath(appDir);
+ Unused << aAppDir->GetPersistentDescriptor(appDir);
PRFileDesc *fd;
nsresult rv =
file->OpenNSPRFileDesc(PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0600, &fd);
if (NS_FAILED(rv)) {
NS_ERROR("could not create output stream");
return;
}
@@ -4512,25 +4518,25 @@ XREMain::XRE_mainRun()
}
// Need to write out the fact that the profile has been removed, the new profile
// renamed, and potentially that the selected/default profile changed.
mProfileSvc->Flush();
}
}
- if (NS_IsNativeUTF8()) {
+#ifndef XP_WIN
nsCOMPtr<nsIFile> profileDir;
nsAutoCString path;
rv = mDirProvider.GetProfileStartupDir(getter_AddRefs(profileDir));
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(profileDir->GetNativePath(path)) && !IsUTF8(path)) {
PR_fprintf(PR_STDERR, "Error: The profile path is not valid UTF-8. Unable to continue.\n");
return NS_ERROR_FAILURE;
}
- }
+#endif
// Initialize user preferences before notifying startup observers so they're
// ready in time for early consumers, such as the component loader.
mDirProvider.InitializeUserPrefs();
{
nsCOMPtr<nsIObserver> startupNotifier
(do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv));