Bug 411505 - Automatic update broken in Swedish and Spanish Windows, r=luser
authorbenjamin@smedbergs.us
Fri, 18 Jan 2008 08:27:44 -0800
changeset 10399 18ad348c1b1202d08e3ed1646102da3a613eb2c1
parent 10398 253ad5b9c79e8a86782cd134a090bd23e47cdffc
child 10400 e5c64ade7391f70907a093fc49bff792c1ec789a
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluser
bugs411505
milestone1.9b3pre
Bug 411505 - Automatic update broken in Swedish and Spanish Windows, r=luser
toolkit/xre/nsUpdateDriver.cpp
--- 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;