David Hedberg : comdlg32: Factor out some path building code from FILEDLG95_OnOpen.

Alexandre Julliard julliard at winehq.org
Fri Apr 1 09:41:05 CDT 2011


Module: wine
Branch: master
Commit: fcb169fe3667126ed256867114c35b39c0ad6cc4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fcb169fe3667126ed256867114c35b39c0ad6cc4

Author: David Hedberg <david.hedberg at gmail.com>
Date:   Fri Apr  1 05:52:29 2011 +0200

comdlg32: Factor out some path building code from FILEDLG95_OnOpen.

---

 dlls/comdlg32/cdlg.h    |    3 ++
 dlls/comdlg32/filedlg.c |   71 +++++++++++++++++++++++++++--------------------
 2 files changed, 44 insertions(+), 30 deletions(-)

diff --git a/dlls/comdlg32/cdlg.h b/dlls/comdlg32/cdlg.h
index 17492a3..fb6280d 100644
--- a/dlls/comdlg32/cdlg.h
+++ b/dlls/comdlg32/cdlg.h
@@ -173,6 +173,9 @@ typedef struct {
 HRESULT FileOpenDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv);
 HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv);
 
+/* Shared helper functions */
+void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile);
+
 /* ITEMIDLIST */
 
 extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST);
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index c65c1f7..84b4eeb 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -568,6 +568,46 @@ static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) {
     return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));
 }
 
+/******************************************************************************
+ * COMDLG32_GetCanonicalPath [internal]
+ *
+ * Helper function to get the canonical path.
+ */
+void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent,
+                               LPWSTR lpstrFile, LPWSTR lpstrPathAndFile)
+{
+  WCHAR lpstrTemp[MAX_PATH];
+
+  /* Get the current directory name */
+  if (!COMDLG32_GetDisplayNameOf(pidlAbsCurrent, lpstrPathAndFile))
+  {
+    /* last fallback */
+    GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
+  }
+  PathAddBackslashW(lpstrPathAndFile);
+
+  TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile));
+
+  /* if the user specified a fully qualified path use it */
+  if(PathIsRelativeW(lpstrFile))
+  {
+    lstrcatW(lpstrPathAndFile, lpstrFile);
+  }
+  else
+  {
+    /* does the path have a drive letter? */
+    if (PathGetDriveNumberW(lpstrFile) == -1)
+      lstrcpyW(lpstrPathAndFile+2, lpstrFile);
+    else
+      lstrcpyW(lpstrPathAndFile, lpstrFile);
+  }
+
+  /* resolve "." and ".." */
+  PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
+  lstrcpyW(lpstrPathAndFile, lpstrTemp);
+  TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
+}
+
 /***********************************************************************
  *      ArrangeCtrlPositions [internal]
  *
@@ -2200,7 +2240,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
   UINT sizeUsed = 0;
   BOOL ret = TRUE;
   WCHAR lpstrPathAndFile[MAX_PATH];
-  WCHAR lpstrTemp[MAX_PATH];
   LPSHELLFOLDER lpsf = NULL;
   int nOpenAction;
   FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
@@ -2234,35 +2273,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
   - the edit box contains ".." (or a path with ".." in it)
 */
 
-  /* Get the current directory name */
-  if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
-  {
-    /* last fallback */
-    GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
-  }
-  PathAddBackslashW(lpstrPathAndFile);
-
-  TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile));
-
-  /* if the user specified a fully qualified path use it */
-  if(PathIsRelativeW(lpstrFileList))
-  {
-    lstrcatW(lpstrPathAndFile, lpstrFileList);
-  }
-  else
-  {
-    /* does the path have a drive letter? */
-    if (PathGetDriveNumberW(lpstrFileList) == -1)
-      lstrcpyW(lpstrPathAndFile+2, lpstrFileList);
-    else
-      lstrcpyW(lpstrPathAndFile, lpstrFileList);
-  }
-
-  /* resolve "." and ".." */
-  PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
-  lstrcpyW(lpstrPathAndFile, lpstrTemp);
-  TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
-
+  COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
   MemFree(lpstrFileList);
 
 /*




More information about the wine-cvs mailing list