From bbb9b6a0fd1c6274e943c75da8cb9c0955fb7c4a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 20 Nov 2007 11:54:58 -0800 Subject: [PATCH] shell32: perform copy in UnixFolder_ISFHelper_CopyItems --- dlls/shell32/shfldr_unixfs.c | 73 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 71 insertions(+), 2 deletions(-) diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c index 6016dc7..6c19001 100644 --- a/dlls/shell32/shfldr_unixfs.c +++ b/dlls/shell32/shfldr_unixfs.c @@ -742,6 +742,61 @@ static HRESULT UNIXFS_initialize_target_ } /****************************************************************************** + * UNIXFS_copy [Internal] + * + * Copy pwszDosSrc to pwszDosDst. + * + * PARAMS + * pwszDosSrc [I] absolute path of the source + * pwszDosDst [I] absolute path of the destination + * + * RETURNS + * Success: S_OK, + * Failure: E_FAIL + */ +static HRESULT UNIXFS_copy(LPCWSTR pwszDosSrc, LPCWSTR pwszDosDst) +{ + SHFILEOPSTRUCTW op; + LPWSTR pwszSrc, pwszDst; + HRESULT res = E_OUTOFMEMORY; + UINT iSrcLen, iDstLen; + + if (!pwszDosSrc || !pwszDosDst) + return E_FAIL; + + iSrcLen = lstrlenW(pwszDosSrc); + iDstLen = lstrlenW(pwszDosDst); + pwszSrc = HeapAlloc(GetProcessHeap(), 0, (iSrcLen + 2) * sizeof(WCHAR)); + pwszDst = HeapAlloc(GetProcessHeap(), 0, (iDstLen + 2) * sizeof(WCHAR)); + + if (pwszSrc && pwszDst) { + lstrcpyW(pwszSrc, pwszDosSrc); + lstrcpyW(pwszDst, pwszDosDst); + /* double null termination */ + pwszSrc[iSrcLen + 1] = 0; + pwszDst[iDstLen + 1] = 0; + + ZeroMemory(&op, sizeof(op)); + op.hwnd = GetActiveWindow(); + op.wFunc = FO_COPY; + op.pFrom = pwszSrc; + op.pTo = pwszDst; + op.fFlags = FOF_ALLOWUNDO; + if (!SHFileOperationW(&op)) + { + WARN("SHFileOperationW failed\n"); + res = E_FAIL; + } + else + res = S_OK; + } + + HeapFree(GetProcessHeap(), 0, pwszSrc); + HeapFree(GetProcessHeap(), 0, pwszDst); + return res; +} + +/****************************************************************************** * UnixFolder * * Class whose heap based instances represent unix filesystem directories. @@ -1864,7 +1919,7 @@ static HRESULT WINAPI UnixFolder_ISFHelp HRESULT hr; char szAbsoluteDst[FILENAME_MAX], *pszRelativeDst; - TRACE("(iface=%p, psfFrom=%p, cidl=%d, apidl=%p): semi-stub\n", iface, psfFrom, cidl, apidl); + TRACE("(iface=%p, psfFrom=%p, cidl=%d, apidl=%p)\n", iface, psfFrom, cidl, apidl); if (!psfFrom || !cidl || !apidl) return E_INVALIDARG; @@ -1882,6 +1937,8 @@ static HRESULT WINAPI UnixFolder_ISFHelp WCHAR wszSrc[MAX_PATH]; char szSrc[FILENAME_MAX]; STRRET strret; + HRESULT res; + WCHAR *pwszDosSrc, *pwszDosDst; /* Build the unix path of the current source item. */ if (FAILED(IShellFolder_GetDisplayNameOf(psfFrom, apidl[i], SHGDN_FORPARSING, &strret))) @@ -1894,7 +1951,19 @@ static HRESULT WINAPI UnixFolder_ISFHelp /* Build the unix path of the current destination item */ UNIXFS_filename_from_shitemid(apidl[i], pszRelativeDst); - FIXME("Would copy %s to %s. Not yet implemented.\n", szSrc, szAbsoluteDst); + pwszDosSrc = wine_get_dos_file_name(szSrc); + pwszDosDst = wine_get_dos_file_name(szAbsoluteDst); + + if (pwszDosSrc && pwszDosDst) + res = UNIXFS_copy(pwszDosSrc, pwszDosDst); + else + res = E_OUTOFMEMORY; + + HeapFree(GetProcessHeap(), 0, pwszDosSrc); + HeapFree(GetProcessHeap(), 0, pwszDosDst); + + if (res != S_OK) + return res; } return S_OK; } -- 1.4.1