- Fix a bug which broke build
[reactos.git] / reactos / dll / win32 / shell32 / shfldr_fs.c
index 072e674..381293d 100644 (file)
@@ -1260,16 +1260,17 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
     WCHAR szTargetPath[MAX_PATH];
     SHFILEOPSTRUCTW op;
     LPITEMIDLIST pidl;
-    LPWSTR pszSrc, pszTarget, pszSrcList, pszTargetList;
-    int res;
+    LPWSTR pszSrc, pszTarget, pszSrcList, pszTargetList, pszFileName;
+    int res, length;
+    HRESULT hr;
     STRRET strRet;
 
     IGenericSFImpl *This = impl_from_ISFHelper(iface);
 
     TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
 
-    IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2);
-    if (ppf2) 
+    hr = IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2);
+    if (SUCCEEDED(hr))
     {
         if (FAILED(IPersistFolder2_GetCurFolder (ppf2, &pidl)))
         {
@@ -1349,8 +1350,26 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
 
         res = SHFileOperationW(&op);
 
-        HeapFree(GetProcessHeap(), 0, pszSrc);
-        HeapFree(GetProcessHeap(), 0, pszTarget);
+        if (res == DE_SAMEFILE)
+        {
+            length = wcslen(szTargetPath);
+
+            pszFileName = wcsrchr(pszSrcList, '\\');
+            pszFileName++;
+
+            if (LoadStringW(shell32_hInstance, IDS_COPY_OF, pszTarget, MAX_PATH - length))
+            {
+                wcscat(szTargetPath, L" ");
+            }
+
+            wcscat(szTargetPath, pszFileName);
+            op.pTo = szTargetPath;
+
+            res = SHFileOperationW(&op);
+        }
+
+        HeapFree(GetProcessHeap(), 0, pszSrcList);
+        HeapFree(GetProcessHeap(), 0, pszTargetList);
 
         if (res)
             return E_FAIL;