filedlg patch.

Rein Klazes rklazes at xs4all.nl
Mon Jan 12 11:56:11 CST 2004


Hi,

PEBrowse Pro, when saving a session file, calls GetOpenFileName() with
initdir pointing to a valid file. This leads to a returned filename like
X:\\path\\to\\foo.exe\\foo.pbs

Changelog:
	dlls/commdlg	: filedlg.c
	Handle the cases when initdir is either invalid, or specifies
	a file.

Rein.
-- 
Rein Klazes
rklazes at xs4all.nl
-------------- next part --------------
--- wine/dlls/commdlg/filedlg.c	2004-01-07 07:35:58.000000000 +0100
+++ mywine/dlls/commdlg/filedlg.c	2004-01-12 17:22:57.000000000 +0100
@@ -1159,19 +1159,31 @@
           DWORD result;
 
           strcpyW(tmpBuf, fodInfos->initdir);
-          if (tmpBuf[strlenW(tmpBuf)-1] != '\\') {
-             strcatW(tmpBuf, szwSlash);
+          if( PathFileExistsW(tmpBuf) ) {
+              /* initdir oes not have to be a directory. If a file is
+               * specified, the dir part is taken */
+              if( PathIsDirectoryW(tmpBuf)) {
+                  if (tmpBuf[strlenW(tmpBuf)-1] != '\\') {
+                     strcatW(tmpBuf, szwSlash);
+                  }
+                  strcatW(tmpBuf, szwStar);
+              }
+              result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
+              if (result) {
+                 *nameBit = 0x00;
+                 if (fodInfos->initdir)
+                    MemFree(fodInfos->initdir);
+                 fodInfos->initdir = MemAlloc((strlenW(tmpBuf2) + 1)*sizeof(WCHAR));
+                 strcpyW(fodInfos->initdir, tmpBuf2);
+                 handledPath = TRUE;
+                 TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
+              }
           }
-          strcatW(tmpBuf, szwStar);
-          result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
-          if (result) {
-             *nameBit = 0x00;
-             if (fodInfos->initdir)
-                MemFree(fodInfos->initdir);
-             fodInfos->initdir = MemAlloc((strlenW(tmpBuf2) + 1)*sizeof(WCHAR));
-             strcpyW(fodInfos->initdir, tmpBuf2);
-             handledPath = TRUE;
-             TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
+          else if (fodInfos->initdir)
+          {
+                    MemFree(fodInfos->initdir);
+                    fodInfos->initdir = NULL;
+                    TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
           }
       }
   }


More information about the wine-patches mailing list