comdlg32: Factor out some path building code from FILEDLG95_OnOpen.

This commit is contained in:
David Hedberg 2011-04-01 05:52:29 +02:00 committed by Alexandre Julliard
parent a172365bd9
commit fcb169fe36
2 changed files with 44 additions and 30 deletions

View File

@ -173,6 +173,9 @@ typedef struct {
HRESULT FileOpenDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv); HRESULT FileOpenDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv);
HRESULT FileSaveDialog_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 */ /* ITEMIDLIST */
extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST); extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST);

View File

@ -568,6 +568,46 @@ static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) {
return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH)); 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] * ArrangeCtrlPositions [internal]
* *
@ -2200,7 +2240,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
UINT sizeUsed = 0; UINT sizeUsed = 0;
BOOL ret = TRUE; BOOL ret = TRUE;
WCHAR lpstrPathAndFile[MAX_PATH]; WCHAR lpstrPathAndFile[MAX_PATH];
WCHAR lpstrTemp[MAX_PATH];
LPSHELLFOLDER lpsf = NULL; LPSHELLFOLDER lpsf = NULL;
int nOpenAction; int nOpenAction;
FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr); FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
@ -2234,35 +2273,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
- the edit box contains ".." (or a path with ".." in it) - the edit box contains ".." (or a path with ".." in it)
*/ */
/* Get the current directory name */ COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
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));
MemFree(lpstrFileList); MemFree(lpstrFileList);
/* /*