Bug 411505 - Automatic update broken in Swedish and Spanish Windows, r=luser
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -323,16 +323,18 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir
rv = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterBin));
return NS_SUCCEEDED(rv);
}
static void
ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsILocalFile *statusFile,
nsIFile *appDir, int appArgc, char **appArgv)
{
+ nsresult rv;
+
// Steps:
// - mark update as 'applying'
// - copy updater into update dir
// - run updater w/ appDir as the current working dir
nsCOMPtr<nsIFile> updater;
if (!CopyUpdaterIntoUpdateDir(greDir, appDir, updateDir, updater)) {
LOG(("failed copying updater\n"));
@@ -348,47 +350,64 @@ ApplyUpdate(nsIFile *greDir, nsIFile *up
// rather than xulrunner-bin. See bug 349737.
GetXULRunnerStubPath(appArgv[0], getter_AddRefs(appFile));
#else
XRE_GetBinaryPath(appArgv[0], getter_AddRefs(appFile));
#endif
if (!appFile)
return;
+
+#ifdef XP_WIN
+ nsAutoString appFilePathW;
+ rv = appFile->GetPath(appFilePathW);
+ if (NS_FAILED(rv))
+ return;
+ NS_ConvertUTF16toUTF8 appFilePath(appFilePathW);
+
+ nsAutoString updaterPathW;
+ rv = updater->GetPath(updaterPathW);
+ if (NS_FAILED(rv))
+ return;
+
+ NS_ConvertUTF16toUTF8 updaterPath(updaterPathW);
+
+#else
nsCAutoString appFilePath;
- nsresult rv = appFile->GetNativePath(appFilePath);
+ rv = appFile->GetNativePath(appFilePath);
if (NS_FAILED(rv))
return;
nsCAutoString updaterPath;
rv = updater->GetNativePath(updaterPath);
if (NS_FAILED(rv))
return;
- nsAutoString updaterPathW;
- rv = updater->GetPath(updaterPathW);
- if (NS_FAILED(rv))
- return;
+#endif
// Get the directory to which the update will be applied. On Mac OSX we need
// to apply the update to the Foo.app directory which is the parent of the
// parent of the appDir. On other platforms we will just apply to the appDir.
+#if defined(XP_MACOSX)
nsCAutoString applyToDir;
-#if defined(XP_MACOSX)
{
nsCOMPtr<nsIFile> parentDir1, parentDir2;
rv = appDir->GetParent(getter_AddRefs(parentDir1));
if (NS_FAILED(rv))
return;
rv = parentDir1->GetParent(getter_AddRefs(parentDir2));
if (NS_FAILED(rv))
return;
rv = parentDir2->GetNativePath(applyToDir);
}
+#elif defined(XP_WIN)
+ nsAutoString applyToDir;
+ rv = appDir->GetPath(applyToDir);
#else
+ nsCAutoString applyToDir;
rv = appDir->GetNativePath(applyToDir);
#endif
if (NS_FAILED(rv))
return;
nsCAutoString updateDirPath;
rv = updateDir->GetNativePath(updateDirPath);
if (NS_FAILED(rv))
@@ -433,17 +452,17 @@ ApplyUpdate(nsIFile *greDir, nsIFile *up
}
LOG(("spawning updater process [%s]\n", updaterPath.get()));
#if defined(USE_EXECV)
chdir(applyToDir.get());
execv(updaterPath.get(), argv);
#elif defined(XP_WIN)
- _chdir(applyToDir.get());
+ _wchdir(applyToDir.get());
if (!WinLaunchChild(updaterPathW.get(), appArgc + 4, argv, 1))
return;
_exit(0);
#else
PRStatus status;
PRProcessAttr *attr;