mirror of
https://github.com/reactos/reactos.git
synced 2024-11-24 12:03:31 +08:00
[SHELL32][SHELLEXT] Fix use of SHFileOperation results and improve log on failure / fix log spam (#3198)
This commit is contained in:
parent
3ad5ae6389
commit
a5a30fc249
@ -157,7 +157,12 @@ CMyDocsDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState,
|
||||
fileop.pFrom = pszzSrcList;
|
||||
fileop.pTo = szzDir;
|
||||
fileop.fFlags = FOF_ALLOWUNDO | FOF_FILESONLY | FOF_MULTIDESTFILES | FOF_NOCONFIRMMKDIR;
|
||||
SHFileOperationW(&fileop);
|
||||
int res = SHFileOperationW(&fileop);
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", res);
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
// unlock buffer
|
||||
strSrcList.ReleaseBuffer();
|
||||
|
@ -211,7 +211,13 @@ HRESULT CCopyToMenu::DoRealCopy(LPCMINVOKECOMMANDINFO lpici, LPCITEMIDLIST pidl)
|
||||
op.pFrom = strFiles;
|
||||
op.pTo = szPath;
|
||||
op.fFlags = FOF_ALLOWUNDO;
|
||||
return ((SHFileOperation(&op) == 0) ? S_OK : E_FAIL);
|
||||
int res = SHFileOperationW(&op);
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", res);
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CStringW CCopyToMenu::DoGetFileTitle()
|
||||
|
@ -178,7 +178,13 @@ HRESULT CMoveToMenu::DoRealMove(LPCMINVOKECOMMANDINFO lpici, LPCITEMIDLIST pidl)
|
||||
op.pFrom = strFiles;
|
||||
op.pTo = szPath;
|
||||
op.fFlags = FOF_ALLOWUNDO;
|
||||
return ((SHFileOperation(&op) == 0) ? S_OK : E_FAIL);
|
||||
int res = SHFileOperationW(&op);
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", res);
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CStringW CMoveToMenu::DoGetFileTitle()
|
||||
|
@ -75,7 +75,7 @@ HRESULT CFSDropTarget::_CopyItems(IShellFolder * pSFFrom, UINT cidl,
|
||||
return hr;
|
||||
|
||||
pszSrcList = BuildPathsList(strretFrom.pOleStr, cidl, apidl);
|
||||
ERR("Source file (just the first) = %s, target path = %s, bCopy: %d\n", debugstr_w(pszSrcList), debugstr_w(m_sPathTarget), bCopy);
|
||||
TRACE("Source file (just the first) = %s, target path = %s, bCopy: %d\n", debugstr_w(pszSrcList), debugstr_w(m_sPathTarget), bCopy);
|
||||
CoTaskMemFree(strretFrom.pOleStr);
|
||||
if (!pszSrcList)
|
||||
return E_OUTOFMEMORY;
|
||||
@ -92,9 +92,11 @@ HRESULT CFSDropTarget::_CopyItems(IShellFolder * pSFFrom, UINT cidl,
|
||||
HeapFree(GetProcessHeap(), 0, pszSrcList);
|
||||
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", res);
|
||||
return E_FAIL;
|
||||
else
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CFSDropTarget::CFSDropTarget():
|
||||
@ -489,7 +491,10 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject,
|
||||
{
|
||||
hr = pDataObject->GetData(&fmt, &medium);
|
||||
TRACE("CFSTR_SHELLIDLIST.\n");
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR("CFSTR_SHELLIDLIST failed\n");
|
||||
}
|
||||
/* lock the handle */
|
||||
LPIDA lpcida = (LPIDA)GlobalLock(medium.hGlobal);
|
||||
if (!lpcida)
|
||||
@ -597,9 +602,9 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject,
|
||||
}
|
||||
|
||||
hr = ppf->Save(wszTarget, FALSE);
|
||||
if (FAILED(hr))
|
||||
break;
|
||||
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, wszTarget, NULL);
|
||||
if (FAILED(hr))
|
||||
break;
|
||||
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, wszTarget, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -636,9 +641,9 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject,
|
||||
break;
|
||||
|
||||
hr = ppf->Save(wszTarget, TRUE);
|
||||
if (FAILED(hr))
|
||||
break;
|
||||
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, wszTarget, NULL);
|
||||
if (FAILED(hr))
|
||||
break;
|
||||
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, wszTarget, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -680,7 +685,13 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject,
|
||||
op.hwnd = m_hwndSite;
|
||||
op.wFunc = bCopy ? FO_COPY : FO_MOVE;
|
||||
op.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR;
|
||||
hr = SHFileOperationW(&op);
|
||||
int res = SHFileOperationW(&op);
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", res);
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
ERR("Error calling GetData\n");
|
||||
|
@ -58,9 +58,10 @@ class CRecyclerDropTarget :
|
||||
FileOp.fFlags = FOF_ALLOWUNDO;
|
||||
TRACE("Deleting file (just the first) = %s, allowundo: %d\n", debugstr_w(FileOp.pFrom), (FileOp.fFlags == FOF_ALLOWUNDO));
|
||||
|
||||
if (SHFileOperationW(&FileOp) != 0)
|
||||
int res = SHFileOperationW(&FileOp);
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperation failed with 0x%x\n", GetLastError());
|
||||
ERR("SHFileOperation failed with 0x%x\n", res);
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
|
@ -503,10 +503,12 @@ RecycleBin5_RecycleBin5_Restore(
|
||||
op.pFrom = pDeletedFileName;
|
||||
op.pTo = pDeletedFile->FileNameW;
|
||||
|
||||
if (!SHFileOperationW(&op))
|
||||
int res = SHFileOperationW(&op);
|
||||
if (res)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", res);
|
||||
UnmapViewOfFile(pHeader);
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* Clear last entry in the file */
|
||||
|
@ -1027,6 +1027,10 @@ int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
|
||||
|
||||
// Call the actual function
|
||||
retCode = SHFileOperationW(&nFileOp);
|
||||
if (retCode)
|
||||
{
|
||||
ERR("SHFileOperationW failed with 0x%x\n", retCode);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
cleanup:
|
||||
|
Loading…
Reference in New Issue
Block a user