Author: janderwald Date: Tue Aug 19 08:03:16 2008 New Revision: 35450
URL: http://svn.reactos.org/svn/reactos?rev=35450&view=rev Log: * Create a IDataObject when cidl == 0 (click on TreeView) * Handle directories in ISFHelper_fnCopyItems * Should make copying directories work
Modified: trunk/reactos/dll/win32/shell32/shfldr_fs.c
Modified: trunk/reactos/dll/win32/shell32/shfldr_fs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shfldr_fs... ============================================================================== --- trunk/reactos/dll/win32/shell32/shfldr_fs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shfldr_fs.c [iso-8859-1] Tue Aug 19 08:03:16 2008 @@ -653,10 +653,17 @@
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) { hr = CDefFolderMenu_Create2(This->pidlRoot, hwndOwner, cidl, apidl, (IShellFolder*)iface, NULL, 0, NULL, (IContextMenu**)&pObj); - } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) { + } else if (IsEqualIID (riid, &IID_IDataObject)){ + if (cidl >= 1) { pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl); hr = S_OK; + } + else + { + pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, (LPCITEMIDLIST*)&This->pidlRoot, 1); + hr = S_OK; + } } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) { pidl = ILCombine (This->pidlRoot, apidl[0]); pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl); @@ -1274,9 +1281,9 @@ WCHAR szTargetPath[MAX_PATH]; SHFILEOPSTRUCTW op; LPITEMIDLIST pidl; - LPWSTR pszSrc, pszTarget; + LPWSTR pszSrc, pszTarget, pszSrcList, pszTargetList; int res; - + STRRET strRet;
IGenericSFImpl *This = impl_from_ISFHelper(iface);
@@ -1290,47 +1297,81 @@ IPersistFolder2_Release(ppf2); return E_FAIL; } - - if (!SHGetPathFromIDListW (pidl, szSrcPath)) + IPersistFolder2_Release(ppf2); + + if (FAILED(IShellFolder_GetDisplayNameOf(pSFFrom, pidl, SHGDN_FORPARSING, &strRet))) { SHFree (pidl); - IPersistFolder2_Release (ppf2); return E_FAIL; } + + if (FAILED(StrRetToBufW(&strRet, pidl, szSrcPath, MAX_PATH))) + { + SHFree (pidl); + return E_FAIL; + } + SHFree (pidl); + pszSrc = PathAddBackslashW (szSrcPath); + wcscpy(szTargetPath, This->sPathTarget); pszTarget = PathAddBackslashW (szTargetPath);
- pszSrc = build_paths_list(szSrcPath, cidl, apidl); - pszTarget = build_paths_list(szTargetPath, cidl, apidl); - - if (!pszSrc || !pszTarget) + pszSrcList = build_paths_list(szSrcPath, cidl, apidl); + pszTargetList = build_paths_list(szTargetPath, cidl, apidl); + + if (!pszSrcList || !pszTargetList) { - if (pszSrc) - HeapFree(GetProcessHeap(), 0, pszSrc); - - if (pszTarget) - HeapFree(GetProcessHeap(), 0, pszTarget); + if (pszSrcList) + HeapFree(GetProcessHeap(), 0, pszSrcList); + + if (pszTargetList) + HeapFree(GetProcessHeap(), 0, pszTargetList);
SHFree (pidl); IPersistFolder2_Release (ppf2); return E_OUTOFMEMORY; } - ZeroMemory(&op, sizeof(op)); + if (!pszSrcList[0]) + { + /* remove trailing backslash */ + pszSrc--; + pszSrc[0] = L'\0'; + op.pFrom = szSrcPath; + } + else + { + op.pFrom = pszSrcList; + } + + if (!pszTargetList[0]) + { + /* remove trailing backslash */ + if (pszTarget - szTargetPath > 3) + { + pszTarget--; + pszTarget[0] = L'\0'; + } + else + { + pszTarget[1] = L'\0'; + } + + op.pTo = szTargetPath; + } + else + { + op.pTo = pszTargetList; + } op.hwnd = GetActiveWindow(); op.wFunc = FO_COPY; - op.pFrom = pszSrc; - op.pTo = pszTarget; - op.fFlags = FOF_ALLOWUNDO; + op.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR;
res = SHFileOperationW(&op);
HeapFree(GetProcessHeap(), 0, pszSrc); HeapFree(GetProcessHeap(), 0, pszTarget); - - SHFree (pidl); - IPersistFolder2_Release (ppf2);
if (res) return E_FAIL;