Bug 773961 - Append '\' only if a path does not end with '\'. r=daveryeo
authorRyan VanderMeulen <ryanvm@gmail.com>
Sat, 21 Jul 2012 14:32:25 -0400
changeset 100040 defbe00ca0916c2f2488c641190c547c84603d72
parent 100039 2a5aa545274d6c3c2be025132a06accdfaea2911
child 100041 292c6ef7188f3275f7411197ead78aed118825de
child 100068 462106f027af8eeadfa78e357f77465df6813ef3
push id12307
push userryanvm@gmail.com
push dateSat, 21 Jul 2012 18:32:33 +0000
treeherdermozilla-inbound@defbe00ca091 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaveryeo
bugs773961
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 773961 - Append '\' only if a path does not end with '\'. r=daveryeo Sometimes, initialDir.get() return a path with '\' at last. In this case, WinFileDlg() fails because of double '\' in a path.
widget/os2/nsFilePicker.cpp
--- a/widget/os2/nsFilePicker.cpp
+++ b/widget/os2/nsFilePicker.cpp
@@ -113,17 +113,19 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16
 
   FILEDLG filedlg;
   memset(&filedlg, 0, sizeof(FILEDLG));
   filedlg.cbSize = sizeof(FILEDLG);
   filedlg.pszTitle = title;
 
   if (mMode == modeGetFolder) {
     PL_strncat(filedlg.szFullFile, initialDir.get(), MAX_PATH);
-    PL_strncat(filedlg.szFullFile, "\\", 1);
+    if (filedlg.szFullFile[0] && 
+        filedlg.szFullFile[strlen(filedlg.szFullFile) - 1] != '\\') 
+      PL_strncat(filedlg.szFullFile, "\\", 1);
     PL_strncat(filedlg.szFullFile, "^", 1);
     filedlg.fl = FDS_OPEN_DIALOG | FDS_CENTER;
     filedlg.pfnDlgProc = DirDialogProc;
     DosError(FERR_DISABLEHARDERR);
     WinFileDlg(HWND_DESKTOP, mWnd, &filedlg);
     DosError(FERR_ENABLEHARDERR);
     char* tempptr = strchr(filedlg.szFullFile, '^');
     if (tempptr)
@@ -134,17 +136,19 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16
         mDisplayDirectory = do_CreateInstance("@mozilla.org/file/local;1");
       if (mDisplayDirectory)
         mDisplayDirectory->InitWithNativePath(nsDependentCString(filedlg.szFullFile));
       mFile.Assign(filedlg.szFullFile);
     }
   }
   else {
     PL_strncpy(filedlg.szFullFile, initialDir.get(), MAX_PATH);
-    PL_strncat(filedlg.szFullFile, "\\", 1);
+    if (filedlg.szFullFile[0] && 
+        filedlg.szFullFile[strlen(filedlg.szFullFile) - 1] != '\\') 
+      PL_strncat(filedlg.szFullFile, "\\", 1);
     PL_strncat(filedlg.szFullFile, fileBuffer.get(), MAX_PATH);
     filedlg.fl = FDS_CENTER;
     if (mMode == modeSave) {
        filedlg.fl |= FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB;
     } else if (mMode == modeOpenMultiple) {
        filedlg.fl |= FDS_MULTIPLESEL | FDS_OPEN_DIALOG;
     } else {
        filedlg.fl |= FDS_OPEN_DIALOG;