shell32: Make ISFHelper_fnCopyItems actually copy the items.

This commit is contained in:
Jay Yang 2011-07-19 12:25:15 -04:00 committed by Alexandre Julliard
parent 01e12ec9f9
commit 872c07a967
1 changed files with 29 additions and 19 deletions

View File

@ -1383,13 +1383,15 @@ static HRESULT WINAPI
ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
LPCITEMIDLIST * apidl)
{
UINT i;
HRESULT ret=E_FAIL;
IPersistFolder2 *ppf2 = NULL;
char szSrcPath[MAX_PATH],
szDstPath[MAX_PATH];
WCHAR wszSrcPathRoot[MAX_PATH],
wszDstPath[MAX_PATH+1];
WCHAR *wszSrcPathsList;
IGenericSFImpl *This = impl_from_ISFHelper(iface);
SHFILEOPSTRUCTW fop;
TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2,
@ -1398,24 +1400,32 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
LPITEMIDLIST pidl;
if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) {
for (i = 0; i < cidl; i++) {
SHGetPathFromIDListA (pidl, szSrcPath);
PathAddBackslashA (szSrcPath);
_ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath),
MAX_PATH);
if (!WideCharToMultiByte(CP_ACP, 0, This->sPathTarget, -1, szDstPath, MAX_PATH, NULL, NULL))
szDstPath[0] = '\0';
PathAddBackslashA (szDstPath);
_ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath),
MAX_PATH);
MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath);
SHGetPathFromIDListW (pidl, wszSrcPathRoot);
ZeroMemory(wszDstPath, MAX_PATH+1);
if (This->sPathTarget)
lstrcpynW(wszDstPath, This->sPathTarget, MAX_PATH);
PathAddBackslashW(wszSrcPathRoot);
PathAddBackslashW(wszDstPath);
wszSrcPathsList = build_paths_list(wszSrcPathRoot, cidl, apidl);
ZeroMemory(&fop, sizeof(fop));
fop.hwnd = GetActiveWindow();
fop.wFunc = FO_COPY;
fop.pFrom = wszSrcPathsList;
fop.pTo = wszDstPath;
fop.fFlags = FOF_ALLOWUNDO;
ret = S_OK;
if(SHFileOperationW(&fop))
{
WARN("Copy failed\n");
ret = E_FAIL;
}
SHFree (pidl);
HeapFree(GetProcessHeap(), 0, wszSrcPathsList);
}
IPersistFolder2_Release (ppf2);
SHFree(pidl);
IPersistFolder2_Release(ppf2);
}
return S_OK;
return ret;
}
static const ISFHelperVtbl shvt =