mirror of
https://github.com/reactos/reactos.git
synced 2025-07-10 06:34:13 +00:00
- rewrite ISFHelper_CopyItems to actually copy the items when requested
- should fix copy&paste of files in explorer (Directories are not yet supported) svn path=/trunk/; revision=35440
This commit is contained in:
parent
2546d4ddc6
commit
eaee8097aa
1 changed files with 60 additions and 24 deletions
|
@ -1269,40 +1269,76 @@ static HRESULT WINAPI
|
||||||
ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
|
ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
|
||||||
LPCITEMIDLIST * apidl)
|
LPCITEMIDLIST * apidl)
|
||||||
{
|
{
|
||||||
UINT i;
|
|
||||||
IPersistFolder2 *ppf2 = NULL;
|
IPersistFolder2 *ppf2 = NULL;
|
||||||
char szSrcPath[MAX_PATH],
|
WCHAR szSrcPath[MAX_PATH];
|
||||||
szDstPath[MAX_PATH];
|
WCHAR szTargetPath[MAX_PATH];
|
||||||
|
SHFILEOPSTRUCTW op;
|
||||||
|
LPITEMIDLIST pidl;
|
||||||
|
LPWSTR pszSrc, pszTarget;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
|
||||||
IGenericSFImpl *This = impl_from_ISFHelper(iface);
|
IGenericSFImpl *This = impl_from_ISFHelper(iface);
|
||||||
|
|
||||||
TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
|
TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
|
||||||
|
|
||||||
IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2,
|
IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2);
|
||||||
(LPVOID *) & ppf2);
|
if (ppf2)
|
||||||
if (ppf2) {
|
{
|
||||||
LPITEMIDLIST pidl;
|
if (FAILED(IPersistFolder2_GetCurFolder (ppf2, &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);
|
|
||||||
}
|
|
||||||
SHFree (pidl);
|
|
||||||
}
|
|
||||||
IPersistFolder2_Release(ppf2);
|
IPersistFolder2_Release(ppf2);
|
||||||
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!SHGetPathFromIDListW (pidl, szSrcPath))
|
||||||
|
{
|
||||||
|
SHFree (pidl);
|
||||||
|
IPersistFolder2_Release (ppf2);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (pszSrc)
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszSrc);
|
||||||
|
|
||||||
|
if (pszTarget)
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszTarget);
|
||||||
|
|
||||||
|
SHFree (pidl);
|
||||||
|
IPersistFolder2_Release (ppf2);
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZeroMemory(&op, sizeof(op));
|
||||||
|
op.hwnd = GetActiveWindow();
|
||||||
|
op.wFunc = FO_COPY;
|
||||||
|
op.pFrom = pszSrc;
|
||||||
|
op.pTo = pszTarget;
|
||||||
|
op.fFlags = FOF_ALLOWUNDO;
|
||||||
|
|
||||||
|
res = SHFileOperationW(&op);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszSrc);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszTarget);
|
||||||
|
|
||||||
|
SHFree (pidl);
|
||||||
|
IPersistFolder2_Release (ppf2);
|
||||||
|
|
||||||
|
if (res)
|
||||||
|
return E_FAIL;
|
||||||
|
else
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
static const ISFHelperVtbl shvt =
|
static const ISFHelperVtbl shvt =
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue