Extending File Dialog to include unix file paths [3/4]
Michael Lin
mlin at corvu.com.au
Thu May 12 23:03:46 CDT 2005
ChangeLog:
- patch from Michael Jung, push pidl to path conversion logic into
shellfolder
- added _ILCreateUnixFolder()
- let desktop shell folder pass unix file path to unix folder for parsing
-------------- next part --------------
Index: dlls/shell32/pidl.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/pidl.c,v
retrieving revision 1.130
diff -u -r1.130 pidl.c
--- dlls/shell32/pidl.c 10 May 2005 08:27:23 -0000 1.130
+++ dlls/shell32/pidl.c 13 May 2005 02:17:11 -0000
@@ -1328,79 +1328,29 @@
HRESULT hr = S_OK;
UINT len;
- pszPath[0]=0;
-
- /* One case is a PIDL rooted at desktop level */
- if (_ILIsDesktop(pidl) ||_ILIsValue(pidl) || _ILIsFolder(pidl))
- {
- hr = SHGetSpecialFolderPathW(0, pszPath, CSIDL_DESKTOP, FALSE);
+ IShellFolder *pDesktop;
+ STRRET strPath;
+ WCHAR *pwszPath;
- if (SUCCEEDED(hr))
- PathAddBackslashW(pszPath);
- }
- /* The only other valid case is an item ID list beginning at "My Computer" */
- else if (_ILIsMyComputer(pidl))
- pidl = ILGetNext(pidl);
-
- if (SUCCEEDED(hr))
- {
- LPSTR txt;
-
- while(pidl && pidl->mkid.cb)
- {
- if (_ILIsSpecialFolder(pidl))
- {
- hr = E_INVALIDARG;
- break;
- }
-
- txt = _ILGetTextPointer(pidl);
- if (!txt)
- {
- hr = E_INVALIDARG;
- break;
- }
-
- if (lstrlenA(txt) > pidl->mkid.cb)
- ERR("pidl %p is borked\n",pidl);
- len = MultiByteToWideChar(CP_ACP, 0, txt, -1, NULL, 0);
- if ( (lstrlenW(pszPath) + len) > uOutSize )
- {
- hr = E_INVALIDARG;
- break;
- }
-
- MultiByteToWideChar(CP_ACP, 0, txt, -1,
- &pszPath[lstrlenW(pszPath)], len);
-
- pidl = ILGetNext(pidl);
- if (!pidl)
- {
- hr = E_INVALIDARG;
- break;
- }
-
- /* Are we at the end and successfully converted the complete PIDL? */
- if (!pidl->mkid.cb)
- break;
-
- if ((lstrlenW(pszPath) + 1) > uOutSize )
- {
- hr = E_INVALIDARG;
- break;
- }
- if (!PathAddBackslashW(pszPath))
- {
- hr = E_INVALIDARG;
- break;
- }
- }
+ pszPath[0]=0;
+
+ /* Push the pidl to path conversion logic into shellfolder */
+ hr = SHGetDesktopFolder(&pDesktop);
+ if (!SUCCEEDED(hr)) return hr;
+ hr = IShellFolder_GetDisplayNameOf(pDesktop, pidl, SHGDN_FORPARSING, &strPath);
+ IShellFolder_Release(pDesktop);
+ if (!SUCCEEDED(hr)) return hr;
+ hr = StrRetToStrW(&strPath, pidl, &pwszPath);
+ if (!SUCCEEDED(hr)) return hr;
+ if (lstrlenW(pwszPath)+1 > uOutSize) {
+ CoTaskMemFree(pszPath);
+ return E_INVALIDARG;
}
- else
- hr = E_INVALIDARG;
-
+ lstrcpyW(pszPath, pwszPath);
+ CoTaskMemFree(pszPath);
+
TRACE_(shell)("-- %s, 0x%08lx\n", debugstr_w(pszPath), hr);
- return hr;
+ return S_OK;
}
/*************************************************************************
@@ -1529,6 +1479,12 @@
{
TRACE("()\n");
return _ILCreateGuid(PT_GUID, &CLSID_MyComputer);
+}
+
+LPITEMIDLIST _ILCreateUnixFolder()
+{
+ TRACE("()\n");
+ return _ILCreateGuid(PT_GUID, &CLSID_UnixFolder);
}
LPITEMIDLIST _ILCreateIExplore()
Index: dlls/shell32/pidl.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/pidl.h,v
retrieving revision 1.47
diff -u -r1.47 pidl.h
--- dlls/shell32/pidl.h 13 Apr 2005 14:39:27 -0000 1.47
+++ dlls/shell32/pidl.h 13 May 2005 02:17:11 -0000
@@ -226,6 +226,7 @@
/* Other helpers */
LPITEMIDLIST _ILCreateMyComputer (void);
+LPITEMIDLIST _ILCreateUnixFolder (void);
LPITEMIDLIST _ILCreateIExplore (void);
LPITEMIDLIST _ILCreateControlPanel (void);
LPITEMIDLIST _ILCreatePrinters (void);
Index: dlls/shell32/shfldr_desktop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shfldr_desktop.c,v
retrieving revision 1.38
diff -u -r1.38 shfldr_desktop.c
--- dlls/shell32/shfldr_desktop.c 10 May 2005 08:28:11 -0000 1.38
+++ dlls/shell32/shfldr_desktop.c 13 May 2005 02:17:12 -0000
@@ -197,6 +197,11 @@
pidlTemp = _ILCreateNetwork();
szNext = lpszDisplayName;
}
+ else if (PathIsUnixAbsoluteW(lpszDisplayName))
+ {
+ pidlTemp = _ILCreateUnixFolder();
+ szNext = lpszDisplayName;
+ }
else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) )
{
*ppidl = pidlTemp;
More information about the wine-patches
mailing list