[ros-diffs] [janderwald] 29749: - fix a few bugs

janderwald at svn.reactos.org janderwald at svn.reactos.org
Sun Oct 21 20:42:01 CEST 2007


Author: janderwald
Date: Sun Oct 21 22:42:01 2007
New Revision: 29749

URL: http://svn.reactos.org/svn/reactos?rev=29749&view=rev
Log:
- fix a few bugs

Modified:
    trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c

Modified: trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c?rev=29749&r1=29748&r2=29749&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c (original)
+++ trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c Sun Oct 21 22:42:01 2007
@@ -34,6 +34,8 @@
 #include "shell32_main.h"
 #include "shellfolder.h"
 #include "undocshell.h"
+#include "shlwapi.h"
+#include "stdio.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(shell);
 
@@ -269,11 +271,11 @@
   PROCESS_INFORMATION pi;
   UINT i, target;
   HANDLE hFile;
-  DWORD dwWritten;
+  DWORD dwWritten, dwError;
 
   static const WCHAR szNew[] = { 'N','e','w',' ',0 }; //FIXME
   static const WCHAR szP1[] = { '%', '1', 0 };
-  static const WCHAR szFormat[] = {'%','s',' ','(','%','u',')','%','s',0 };
+  static const WCHAR szFormat[] = {'%','s',' ','(','%','d',')','%','s',0 };
   
 
   i = This->iIdShellNewFirst;
@@ -317,7 +319,7 @@
         ERR("IShellFolder_GetDisplayNameOf failed\n");
         return;
      }
-     StrRetToBufW(strTemp, pidl, szPath, MAX_PATH);
+     StrRetToBufW(&strTemp, pidl, szPath, MAX_PATH);
   }
   switch(pCurItem->Type)
   {
@@ -336,7 +338,7 @@
          if (ptr)
          {
             ptr[1] = 's';
-            swprintf(szTemp, szBuffer, szPath);
+            sprintfW(szTemp, szBuffer, szPath);
             ptr = szTemp;
          }
          else
@@ -370,25 +372,35 @@
         wcscat(szBuffer, pCurItem->szExt);
         do
         {
-            TRACE("FileName %s szBuffer %s i %d \n", debugstr_w(szBuffer), debugstr_w(szPath), i);
             hFile = CreateFileW(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
-            swprintf(szBuffer, szFormat, szPath, i, pCurItem->szExt);
+            if (hFile != INVALID_HANDLE_VALUE)
+                break;
+            dwError = GetLastError();
+
+            TRACE("FileName %s szBuffer %s i %u error %x\n", debugstr_w(szBuffer), debugstr_w(szPath), i, dwError);
+            sprintfW(szBuffer, szFormat, szPath, i, pCurItem->szExt);
             i++;
-        }while(hFile == INVALID_HANDLE_VALUE);
+        }while(hFile == INVALID_HANDLE_VALUE && dwError == ERROR_FILE_EXISTS);
+
+        if (hFile == INVALID_HANDLE_VALUE)
+            return;
 
         if (pCurItem->Type == SHELLNEW_TYPE_DATA)
         {
-            i = WideCharToMultiByte(CP_ACP, 0, pCurItem->szTarget, -1, (LPSTR)szBuffer, MAX_PATH*2, NULL, NULL);
+            i = WideCharToMultiByte(CP_ACP, 0, pCurItem->szTarget, -1, (LPSTR)szTemp, MAX_PATH*2, NULL, NULL);
             if (i)
             {
-                WriteFile(hFile, (LPCVOID)szBuffer, i, &dwWritten, NULL);
+                WriteFile(hFile, (LPCVOID)szTemp, i, &dwWritten, NULL);
             }
         }
         CloseHandle(hFile);
         if (pCurItem->Type == SHELLNEW_TYPE_FILENAME)
         {
-            CopyFileW(pCurItem->szTarget, szPath, FALSE);
+            if (!CopyFileW(pCurItem->szTarget, szBuffer, FALSE))
+                break;
         }
+        TRACE("Notifying fs %s\n", debugstr_w(szBuffer));
+        SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, (LPCVOID)szBuffer, NULL);
         break;
      }
   }




More information about the Ros-diffs mailing list