[PATCH] shell32: Correct indentation in shfileop.c.

Vijay Kiran Kamuju infyquest at gmail.com
Tue Apr 2 11:11:58 CDT 2019


From: Michael Müller <michael at fds-team.de>

Remove tabs and replace whitespaces

From: Michael Müller <michael at fds-team.de>
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
---
 dlls/shell32/shlfileop.c | 794 +++++++++++++++++++--------------------
 1 file changed, 396 insertions(+), 398 deletions(-)

diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index c7bd54d200b..d2252fb1420 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -207,108 +207,107 @@ static int SHELL_ConfirmMsgBox(HWND hWnd, LPWSTR lpszText, LPWSTR lpszCaption, H
 /* confirmation dialogs content */
 typedef struct
 {
-        HINSTANCE hIconInstance;
-        UINT icon_resource_id;
-	UINT caption_resource_id, text_resource_id;
+    HINSTANCE hIconInstance;
+    UINT icon_resource_id;
+    UINT caption_resource_id, text_resource_id;
 } SHELL_ConfirmIDstruc;
 
 static BOOL SHELL_ConfirmIDs(int nKindOfDialog, SHELL_ConfirmIDstruc *ids)
 {
-        ids->hIconInstance = shell32_hInstance;
-	switch (nKindOfDialog) {
-	  case ASK_DELETE_FILE:
-            ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
-	    ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
-	    ids->text_resource_id  = IDS_DELETEITEM_TEXT;
-	    return TRUE;
-	  case ASK_DELETE_FOLDER:
-            ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
-	    ids->caption_resource_id  = IDS_DELETEFOLDER_CAPTION;
-	    ids->text_resource_id  = IDS_DELETEITEM_TEXT;
-	    return TRUE;
-	  case ASK_DELETE_MULTIPLE_ITEM:
-            ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
-	    ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
-	    ids->text_resource_id  = IDS_DELETEMULTIPLE_TEXT;
-	    return TRUE;
-          case ASK_TRASH_FILE:
-            ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
-            ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
-            ids->text_resource_id = IDS_TRASHITEM_TEXT;
-            return TRUE;
-          case ASK_TRASH_FOLDER:
-            ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
-            ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
-            ids->text_resource_id = IDS_TRASHFOLDER_TEXT;
-            return TRUE;
-          case ASK_TRASH_MULTIPLE_ITEM:
-            ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
-            ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
-            ids->text_resource_id = IDS_TRASHMULTIPLE_TEXT;
-            return TRUE;
-          case ASK_CANT_TRASH_ITEM:
-            ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
-            ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
-            ids->text_resource_id  = IDS_CANTTRASH_TEXT;
-            return TRUE;
-	  case ASK_DELETE_SELECTED:
-            ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
+    ids->hIconInstance = shell32_hInstance;
+    switch (nKindOfDialog) {
+        case ASK_DELETE_FILE:
+             ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
             ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
-            ids->text_resource_id  = IDS_DELETESELECTED_TEXT;
+            ids->text_resource_id  = IDS_DELETEITEM_TEXT;
             return TRUE;
-	  case ASK_OVERWRITE_FILE:
-            ids->hIconInstance = NULL;
-            ids->icon_resource_id = IDI_WARNING;
-	    ids->caption_resource_id  = IDS_OVERWRITEFILE_CAPTION;
-	    ids->text_resource_id  = IDS_OVERWRITEFILE_TEXT;
+        case ASK_DELETE_FOLDER:
+             ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
+            ids->caption_resource_id  = IDS_DELETEFOLDER_CAPTION;
+            ids->text_resource_id  = IDS_DELETEITEM_TEXT;
             return TRUE;
-	  case ASK_OVERWRITE_FOLDER:
-            ids->hIconInstance = NULL;
-            ids->icon_resource_id = IDI_WARNING;
-            ids->caption_resource_id  = IDS_OVERWRITEFILE_CAPTION;
-            ids->text_resource_id  = IDS_OVERWRITEFOLDER_TEXT;
+        case ASK_DELETE_MULTIPLE_ITEM:
+             ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
+            ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
+            ids->text_resource_id  = IDS_DELETEMULTIPLE_TEXT;
             return TRUE;
-	  default:
-	    FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog);
-	}
-	return FALSE;
+        case ASK_TRASH_FILE:
+             ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
+             ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
+             ids->text_resource_id = IDS_TRASHITEM_TEXT;
+             return TRUE;
+        case ASK_TRASH_FOLDER:
+             ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
+             ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
+             ids->text_resource_id = IDS_TRASHFOLDER_TEXT;
+             return TRUE;
+        case ASK_TRASH_MULTIPLE_ITEM:
+             ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
+             ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
+             ids->text_resource_id = IDS_TRASHMULTIPLE_TEXT;
+             return TRUE;
+        case ASK_CANT_TRASH_ITEM:
+             ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
+             ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
+             ids->text_resource_id  = IDS_CANTTRASH_TEXT;
+             return TRUE;
+        case ASK_DELETE_SELECTED:
+             ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
+             ids->caption_resource_id  = IDS_DELETEITEM_CAPTION;
+             ids->text_resource_id  = IDS_DELETESELECTED_TEXT;
+             return TRUE;
+        case ASK_OVERWRITE_FILE:
+             ids->hIconInstance = NULL;
+             ids->icon_resource_id = IDI_WARNING;
+             ids->caption_resource_id  = IDS_OVERWRITEFILE_CAPTION;
+             ids->text_resource_id  = IDS_OVERWRITEFILE_TEXT;
+             return TRUE;
+        case ASK_OVERWRITE_FOLDER:
+             ids->hIconInstance = NULL;
+             ids->icon_resource_id = IDI_WARNING;
+             ids->caption_resource_id  = IDS_OVERWRITEFILE_CAPTION;
+             ids->text_resource_id  = IDS_OVERWRITEFOLDER_TEXT;
+             return TRUE;
+        default:
+            FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog);
+   }
+   return FALSE;
 }
 
 static BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FILE_OPERATION *op)
 {
-	WCHAR szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
-	SHELL_ConfirmIDstruc ids;
-	DWORD_PTR args[1];
-	HICON hIcon;
-	int ret;
-
-        assert(nKindOfDialog >= 0 && nKindOfDialog < 32);
-        if (op && (op->dwYesToAllMask & (1 << nKindOfDialog)))
-            return TRUE;
-
-        if (!SHELL_ConfirmIDs(nKindOfDialog, &ids)) return FALSE;
-
-        LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, ARRAY_SIZE(szCaption));
-        LoadStringW(shell32_hInstance, ids.text_resource_id, szText, ARRAY_SIZE(szText));
-
-        args[0] = (DWORD_PTR)szDir;
-        FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
-            szText, 0, 0, szBuffer, ARRAY_SIZE(szBuffer), (__ms_va_list*)args);
-
-        hIcon = LoadIconW(ids.hIconInstance, (LPWSTR)MAKEINTRESOURCE(ids.icon_resource_id));
+    WCHAR szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
+    SHELL_ConfirmIDstruc ids;
+    DWORD_PTR args[1];
+    HICON hIcon;
+    int ret;
 
-        ret = SHELL_ConfirmMsgBox(hWnd, szBuffer, szCaption, hIcon, op && op->bManyItems);
-        if (op) {
-            if (ret == IDD_YESTOALL) {
-                op->dwYesToAllMask |= (1 << nKindOfDialog);
-                ret = IDYES;
-            }
-            if (ret == IDCANCEL)
-                op->bCancelled = TRUE;
-            if (ret != IDYES)
-                op->req->fAnyOperationsAborted = TRUE;
-        }
-        return ret == IDYES;
+    assert(nKindOfDialog >= 0 && nKindOfDialog < 32);
+    if (op && (op->dwYesToAllMask & (1 << nKindOfDialog)))
+        return TRUE;
+
+    if (!SHELL_ConfirmIDs(nKindOfDialog, &ids)) return FALSE;
+
+    LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, ARRAY_SIZE(szCaption));
+    LoadStringW(shell32_hInstance, ids.text_resource_id, szText, ARRAY_SIZE(szText));
+
+    args[0] = (DWORD_PTR)szDir;
+    FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
+        szText, 0, 0, szBuffer, ARRAY_SIZE(szBuffer), (__ms_va_list*)args);
+    hIcon = LoadIconW(ids.hIconInstance, (LPWSTR)MAKEINTRESOURCE(ids.icon_resource_id));
+
+    ret = SHELL_ConfirmMsgBox(hWnd, szBuffer, szCaption, hIcon, op && op->bManyItems);
+    if (op) {
+        if (ret == IDD_YESTOALL) {
+            op->dwYesToAllMask |= (1 << nKindOfDialog);
+            ret = IDYES;
+         }
+        if (ret == IDCANCEL)
+            op->bCancelled = TRUE;
+        if (ret != IDYES)
+            op->req->fAnyOperationsAborted = TRUE;
+    }
+    return ret == IDYES;
 }
 
 BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir)
@@ -318,18 +317,18 @@ BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir)
 
 static DWORD SHELL32_AnsiToUnicodeBuf(LPCSTR aPath, LPWSTR *wPath, DWORD minChars)
 {
-	DWORD len = MultiByteToWideChar(CP_ACP, 0, aPath, -1, NULL, 0);
-
-	if (len < minChars)
-	  len = minChars;
-
-	*wPath = heap_alloc(len * sizeof(WCHAR));
-	if (*wPath)
-	{
-	  MultiByteToWideChar(CP_ACP, 0, aPath, -1, *wPath, len);
-	  return NO_ERROR;
-	}
-	return E_OUTOFMEMORY;
+    DWORD len = MultiByteToWideChar(CP_ACP, 0, aPath, -1, NULL, 0);
+
+    if (len < minChars)
+      len = minChars;
+
+    *wPath = heap_alloc(len * sizeof(WCHAR));
+    if (*wPath)
+    {
+        MultiByteToWideChar(CP_ACP, 0, aPath, -1, *wPath, len);
+        return NO_ERROR;
+    }
+    return E_OUTOFMEMORY;
 }
 
 HRESULT WINAPI SHIsFileAvailableOffline(LPCWSTR path, LPDWORD status)
@@ -372,8 +371,8 @@ static DWORD SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pszDir, BOOL bShowUI)
         ret = SHNotifyRemoveDirectoryW(pszDir);
 
     return ret == ERROR_PATH_NOT_FOUND ?
-        0x7C: /* DE_INVALIDFILES (legacy Windows error) */
-        ret;
+                  0x7C: /* DE_INVALIDFILES (legacy Windows error) */
+                  ret;
 }
 
 /**************************************************************************
@@ -393,41 +392,41 @@ static DWORD SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pszDir, BOOL bShowUI)
  */
 static DWORD SHNotifyCreateDirectoryA(LPCSTR path, LPSECURITY_ATTRIBUTES sec)
 {
-	LPWSTR wPath;
-	DWORD retCode;
-
-	TRACE("(%s, %p)\n", debugstr_a(path), sec);
-
-	retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
-	if (!retCode)
-	{
-	  retCode = SHNotifyCreateDirectoryW(wPath, sec);
-	  heap_free(wPath);
-	}
-	return retCode;
+    LPWSTR wPath;
+    DWORD retCode;
+
+    TRACE("(%s, %p)\n", debugstr_a(path), sec);
+
+    retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
+    if (!retCode)
+    {
+        retCode = SHNotifyCreateDirectoryW(wPath, sec);
+        heap_free(wPath);
+    }
+    return retCode;
 }
 
 /**********************************************************************/
 
 static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
 {
-	TRACE("(%s, %p)\n", debugstr_w(path), sec);
-
-	if (CreateDirectoryW(path, sec))
-	{
-	  SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL);
-	  return ERROR_SUCCESS;
-	}
-	return GetLastError();
+    TRACE("(%s, %p)\n", debugstr_w(path), sec);
+
+    if (CreateDirectoryW(path, sec))
+    {
+        SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL);
+        return ERROR_SUCCESS;
+    }
+    return GetLastError();
 }
 
 /**********************************************************************/
 
 BOOL WINAPI Win32CreateDirectoryAW(LPCVOID path, LPSECURITY_ATTRIBUTES sec)
 {
-	if (SHELL_OsIsUnicode())
-	  return (SHNotifyCreateDirectoryW(path, sec) == ERROR_SUCCESS);
-	return (SHNotifyCreateDirectoryA(path, sec) == ERROR_SUCCESS);
+    if (SHELL_OsIsUnicode())
+        return (SHNotifyCreateDirectoryW(path, sec) == ERROR_SUCCESS);
+    return (SHNotifyCreateDirectoryA(path, sec) == ERROR_SUCCESS);
 }
 
 /************************************************************************
@@ -447,51 +446,51 @@ BOOL WINAPI Win32CreateDirectoryAW(LPCVOID path, LPSECURITY_ATTRIBUTES sec)
  */
 static DWORD SHNotifyRemoveDirectoryA(LPCSTR path)
 {
-	LPWSTR wPath;
-	DWORD retCode;
-
-	TRACE("(%s)\n", debugstr_a(path));
-
-	retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
-	if (!retCode)
-	{
-	  retCode = SHNotifyRemoveDirectoryW(wPath);
-	  heap_free(wPath);
-	}
-	return retCode;
+    LPWSTR wPath;
+    DWORD retCode;
+
+    TRACE("(%s)\n", debugstr_a(path));
+
+    retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
+    if (!retCode)
+    {
+        retCode = SHNotifyRemoveDirectoryW(wPath);
+        heap_free(wPath);
+    }
+    return retCode;
 }
 
 /***********************************************************************/
 
 static DWORD SHNotifyRemoveDirectoryW(LPCWSTR path)
 {
-	BOOL ret;
-	TRACE("(%s)\n", debugstr_w(path));
-
-	ret = RemoveDirectoryW(path);
-	if (!ret)
-	{
-	  /* Directory may be write protected */
-	  DWORD dwAttr = GetFileAttributesW(path);
-	  if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY))
-	    if (SetFileAttributesW(path, dwAttr & ~FILE_ATTRIBUTE_READONLY))
-	      ret = RemoveDirectoryW(path);
-	}
-	if (ret)
-	{
-	  SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, path, NULL);
-	  return ERROR_SUCCESS;
-	}
-	return GetLastError();
+    BOOL ret;
+    TRACE("(%s)\n", debugstr_w(path));
+
+    ret = RemoveDirectoryW(path);
+    if (!ret)
+    {
+        /* Directory may be write protected */
+        DWORD dwAttr = GetFileAttributesW(path);
+        if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY))
+            if (SetFileAttributesW(path, dwAttr & ~FILE_ATTRIBUTE_READONLY))
+                ret = RemoveDirectoryW(path);
+    }
+    if (ret)
+    {
+        SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, path, NULL);
+        return ERROR_SUCCESS;
+    }
+    return GetLastError();
 }
 
 /***********************************************************************/
 
 BOOL WINAPI Win32RemoveDirectoryAW(LPCVOID path)
 {
-	if (SHELL_OsIsUnicode())
-	  return (SHNotifyRemoveDirectoryW(path) == ERROR_SUCCESS);
-	return (SHNotifyRemoveDirectoryA(path) == ERROR_SUCCESS);
+    if (SHELL_OsIsUnicode())
+        return (SHNotifyRemoveDirectoryW(path) == ERROR_SUCCESS);
+    return (SHNotifyRemoveDirectoryA(path) == ERROR_SUCCESS);
 }
 
 /************************************************************************
@@ -511,52 +510,52 @@ BOOL WINAPI Win32RemoveDirectoryAW(LPCVOID path)
  */
 static DWORD SHNotifyDeleteFileA(LPCSTR path)
 {
-	LPWSTR wPath;
-	DWORD retCode;
-
-	TRACE("(%s)\n", debugstr_a(path));
-
-	retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
-	if (!retCode)
-	{
-	  retCode = SHNotifyDeleteFileW(wPath);
-	  heap_free(wPath);
-	}
-	return retCode;
+    LPWSTR wPath;
+    DWORD retCode;
+
+    TRACE("(%s)\n", debugstr_a(path));
+
+    retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
+    if (!retCode)
+    {
+        retCode = SHNotifyDeleteFileW(wPath);
+        heap_free(wPath);
+    }
+    return retCode;
 }
 
 /***********************************************************************/
 
 static DWORD SHNotifyDeleteFileW(LPCWSTR path)
 {
-	BOOL ret;
-
-	TRACE("(%s)\n", debugstr_w(path));
-
-	ret = DeleteFileW(path);
-	if (!ret)
-	{
-	  /* File may be write protected or a system file */
-	  DWORD dwAttr = GetFileAttributesW(path);
-	  if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
-	    if (SetFileAttributesW(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
-	      ret = DeleteFileW(path);
-	}
-	if (ret)
-	{
-	  SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, path, NULL);
-	  return ERROR_SUCCESS;
-	}
-	return GetLastError();
+    BOOL ret;
+
+    TRACE("(%s)\n", debugstr_w(path));
+
+    ret = DeleteFileW(path);
+    if (!ret)
+    {
+        /* File may be write protected or a system file */
+        DWORD dwAttr = GetFileAttributesW(path);
+        if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
+            if (SetFileAttributesW(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
+                ret = DeleteFileW(path);
+    }
+    if (ret)
+    {
+        SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, path, NULL);
+        return ERROR_SUCCESS;
+    }
+    return GetLastError();
 }
 
 /***********************************************************************/
 
 DWORD WINAPI Win32DeleteFileAW(LPCVOID path)
 {
-	if (SHELL_OsIsUnicode())
-	  return (SHNotifyDeleteFileW(path) == ERROR_SUCCESS);
-	return (SHNotifyDeleteFileA(path) == ERROR_SUCCESS);
+    if (SHELL_OsIsUnicode())
+        return (SHNotifyDeleteFileW(path) == ERROR_SUCCESS);
+    return (SHNotifyDeleteFileA(path) == ERROR_SUCCESS);
 }
 
 /************************************************************************
@@ -573,36 +572,36 @@ DWORD WINAPI Win32DeleteFileAW(LPCVOID path)
  */
 static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest)
 {
-	BOOL ret;
-
-	TRACE("(%s %s)\n", debugstr_w(src), debugstr_w(dest));
-
-        ret = MoveFileExW(src, dest, MOVEFILE_REPLACE_EXISTING);
-
-        /* MOVEFILE_REPLACE_EXISTING fails with dirs, so try MoveFile */
-        if (!ret)
-            ret = MoveFileW(src, dest);
-
-	if (!ret)
-	{
-	  DWORD dwAttr;
-
-	  dwAttr = SHFindAttrW(dest, FALSE);
-	  if (INVALID_FILE_ATTRIBUTES == dwAttr)
-	  {
-	    /* Source file may be write protected or a system file */
-	    dwAttr = GetFileAttributesW(src);
-	    if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
-	      if (SetFileAttributesW(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
-	        ret = MoveFileW(src, dest);
-	  }
-	}
-	if (ret)
-	{
-	  SHChangeNotify(SHCNE_RENAMEITEM, SHCNF_PATHW, src, dest);
-	  return ERROR_SUCCESS;
-	}
-	return GetLastError();
+    BOOL ret;
+
+    TRACE("(%s %s)\n", debugstr_w(src), debugstr_w(dest));
+
+    ret = MoveFileExW(src, dest, MOVEFILE_REPLACE_EXISTING);
+
+    /* MOVEFILE_REPLACE_EXISTING fails with dirs, so try MoveFile */
+    if (!ret)
+        ret = MoveFileW(src, dest);
+
+    if (!ret)
+    {
+        DWORD dwAttr;
+
+        dwAttr = SHFindAttrW(dest, FALSE);
+        if (INVALID_FILE_ATTRIBUTES == dwAttr)
+        {
+            /* Source file may be write protected or a system file */
+            dwAttr = GetFileAttributesW(src);
+            if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
+                if (SetFileAttributesW(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
+                    ret = MoveFileW(src, dest);
+        }
+    }
+    if (ret)
+    {
+        SHChangeNotify(SHCNE_RENAMEITEM, SHCNF_PATHW, src, dest);
+        return ERROR_SUCCESS;
+    }
+    return GetLastError();
 }
 
 /************************************************************************
@@ -621,24 +620,24 @@ static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest)
  */
 static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
 {
-	BOOL ret;
-	DWORD attribs;
+    BOOL ret;
+    DWORD attribs;
 
-	TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bFailIfExists ? "failIfExists" : "");
+    TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bFailIfExists ? "failIfExists" : "");
 
-        /* Destination file may already exist with read only attribute */
-        attribs = GetFileAttributesW(dest);
-        if (IsAttrib(attribs, FILE_ATTRIBUTE_READONLY))
-          SetFileAttributesW(dest, attribs & ~FILE_ATTRIBUTE_READONLY);
+    /* Destination file may already exist with read only attribute */
+    attribs = GetFileAttributesW(dest);
+    if (IsAttrib(attribs, FILE_ATTRIBUTE_READONLY))
+        SetFileAttributesW(dest, attribs & ~FILE_ATTRIBUTE_READONLY);
 
-	ret = CopyFileW(src, dest, bFailIfExists);
-	if (ret)
-	{
-	  SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, dest, NULL);
-	  return ERROR_SUCCESS;
-	}
+    ret = CopyFileW(src, dest, bFailIfExists);
+    if (ret)
+    {
+        SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, dest, NULL);
+        return ERROR_SUCCESS;
+    }
 
-	return GetLastError();
+    return GetLastError();
 }
 
 /*************************************************************************
@@ -668,9 +667,9 @@ static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
  */
 DWORD WINAPI SHCreateDirectory(HWND hWnd, LPCVOID path)
 {
-	if (SHELL_OsIsUnicode())
-	  return SHCreateDirectoryExW(hWnd, path, NULL);
-	return SHCreateDirectoryExA(hWnd, path, NULL);
+    if (SHELL_OsIsUnicode())
+        return SHCreateDirectoryExW(hWnd, path, NULL);
+    return SHCreateDirectoryExA(hWnd, path, NULL);
 }
 
 /*************************************************************************
@@ -707,18 +706,18 @@ DWORD WINAPI SHCreateDirectory(HWND hWnd, LPCVOID path)
  */
 int WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec)
 {
-	LPWSTR wPath;
-	DWORD retCode;
-
-	TRACE("(%s, %p)\n", debugstr_a(path), sec);
-
-	retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
-	if (!retCode)
-	{
-	  retCode = SHCreateDirectoryExW(hWnd, wPath, sec);
-	  heap_free(wPath);
-	}
-	return retCode;
+    LPWSTR wPath;
+    DWORD retCode;
+
+    TRACE("(%s, %p)\n", debugstr_a(path), sec);
+
+    retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
+    if (!retCode)
+    {
+        retCode = SHCreateDirectoryExW(hWnd, wPath, sec);
+        heap_free(wPath);
+    }
+    return retCode;
 }
 
 /*************************************************************************
@@ -728,49 +727,49 @@ int WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES se
  */
 int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
 {
-	int ret = ERROR_BAD_PATHNAME;
-	TRACE("(%p, %s, %p)\n", hWnd, debugstr_w(path), sec);
-
-	if (PathIsRelativeW(path))
-	{
-	  SetLastError(ret);
-	}
-	else
-	{
-	  ret = SHNotifyCreateDirectoryW(path, sec);
-	  /* Refuse to work on certain error codes before trying to create directories recursively */
-	  if (ret != ERROR_SUCCESS &&
-	      ret != ERROR_FILE_EXISTS &&
-	      ret != ERROR_ALREADY_EXISTS &&
-	      ret != ERROR_FILENAME_EXCED_RANGE)
-	  {
-	    WCHAR *pEnd, *pSlash, szTemp[MAX_PATH + 1];  /* extra for PathAddBackslash() */
-
-	    lstrcpynW(szTemp, path, MAX_PATH);
-	    pEnd = PathAddBackslashW(szTemp);
-	    pSlash = szTemp + 3;
-
-	    while (*pSlash)
-	    {
-              while (*pSlash && *pSlash != '\\') pSlash++;
-	      if (*pSlash)
-	      {
-	        *pSlash = 0;    /* terminate path at separator */
-
-	        ret = SHNotifyCreateDirectoryW(szTemp, pSlash + 1 == pEnd ? sec : NULL);
-	      }
-	      *pSlash++ = '\\'; /* put the separator back */
-	    }
-	  }
-
-	  if (ret && hWnd && (ERROR_CANCELLED != ret))
-	  {
-	    /* We failed and should show a dialog box */
-	    FIXME("Show system error message, creating path %s, failed with error %d\n", debugstr_w(path), ret);
-	    ret = ERROR_CANCELLED; /* Error has been already presented to user (not really yet!) */
-	  }
-	}
-	return ret;
+    int ret = ERROR_BAD_PATHNAME;
+    TRACE("(%p, %s, %p)\n", hWnd, debugstr_w(path), sec);
+
+    if (PathIsRelativeW(path))
+    {
+        SetLastError(ret);
+    }
+    else
+    {
+        ret = SHNotifyCreateDirectoryW(path, sec);
+        /* Refuse to work on certain error codes before trying to create directories recursively */
+        if (ret != ERROR_SUCCESS &&
+            ret != ERROR_FILE_EXISTS &&
+            ret != ERROR_ALREADY_EXISTS &&
+            ret != ERROR_FILENAME_EXCED_RANGE)
+        {
+            WCHAR *pEnd, *pSlash, szTemp[MAX_PATH + 1];  /* extra for PathAddBackslash() */
+
+            lstrcpynW(szTemp, path, MAX_PATH);
+            pEnd = PathAddBackslashW(szTemp);
+            pSlash = szTemp + 3;
+
+            while (*pSlash)
+            {
+                while (*pSlash && *pSlash != '\\') pSlash++;
+                if (*pSlash)
+                {
+                    *pSlash = 0;    /* terminate path at separator */
+
+                    ret = SHNotifyCreateDirectoryW(szTemp, pSlash + 1 == pEnd ? sec : NULL);
+                }
+                *pSlash++ = '\\'; /* put the separator back */
+            }
+        }
+
+        if (ret && hWnd && (ERROR_CANCELLED != ret))
+        {
+            /* We failed and should show a dialog box */
+            FIXME("Show system error message, creating path %s, failed with error %d\n", debugstr_w(path), ret);
+            ret = ERROR_CANCELLED; /* Error has been already presented to user (not really yet!) */
+        }
+    }
+    return ret;
 }
 
 /*************************************************************************
@@ -790,25 +789,25 @@ int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES s
  */
 static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly)
 {
-	WIN32_FIND_DATAW wfd;
-	BOOL b_FileMask = fileOnly && (NULL != StrPBrkW(pName, wWildcardChars));
-	DWORD dwAttr = INVALID_FILE_ATTRIBUTES;
-	HANDLE hFind = FindFirstFileW(pName, &wfd);
-
-	TRACE("%s %d\n", debugstr_w(pName), fileOnly);
-	if (INVALID_HANDLE_VALUE != hFind)
-	{
-	  do
-	  {
-	    if (b_FileMask && IsAttribDir(wfd.dwFileAttributes))
-	       continue;
-	    dwAttr = wfd.dwFileAttributes;
-	    break;
-	  }
-	  while (FindNextFileW(hFind, &wfd));
-	  FindClose(hFind);
-	}
-	return dwAttr;
+    WIN32_FIND_DATAW wfd;
+    BOOL b_FileMask = fileOnly && (NULL != StrPBrkW(pName, wWildcardChars));
+    DWORD dwAttr = INVALID_FILE_ATTRIBUTES;
+    HANDLE hFind = FindFirstFileW(pName, &wfd);
+
+    TRACE("%s %d\n", debugstr_w(pName), fileOnly);
+    if (INVALID_HANDLE_VALUE != hFind)
+    {
+        do
+        {
+            if (b_FileMask && IsAttribDir(wfd.dwFileAttributes))
+                continue;
+            dwAttr = wfd.dwFileAttributes;
+            break;
+        }
+        while (FindNextFileW(hFind, &wfd));
+        FindClose(hFind);
+    }
+    return dwAttr;
 }
 
 /*************************************************************************
@@ -822,27 +821,27 @@ static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly)
  */
 static DWORD SHNameTranslate(LPWSTR* wString, LPCWSTR* pWToFrom, BOOL more)
 {
-	DWORD size = 0, aSize = 0;
-	LPCSTR aString = (LPCSTR)*pWToFrom;
-
-	if (aString)
-	{
-	  do
-	  {
-	    size = lstrlenA(aString) + 1;
-	    aSize += size;
-	    aString += size;
-	  } while ((size != 1) && more);
-	  /* The two sizes might be different in the case of multibyte chars */
-	  size = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, 0);
-	  if (*wString) /* only in the second loop */
-	  {
-	    MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, size);
-	    *pWToFrom = *wString;
-	    *wString += size;
-	  }
-	}
-	return size;
+    DWORD size = 0, aSize = 0;
+    LPCSTR aString = (LPCSTR)*pWToFrom;
+
+    if (aString)
+    {
+        do
+        {
+            size = lstrlenA(aString) + 1;
+            aSize += size;
+            aString += size;
+        } while ((size != 1) && more);
+        /* The two sizes might be different in the case of multibyte chars */
+        size = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, 0);
+        if (*wString) /* only in the second loop */
+        {
+            MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, size);
+            *pWToFrom = *wString;
+            *wString += size;
+        }
+    }
+    return size;
 }
 /*************************************************************************
  * SHFileOperationA          [SHELL32.@]
@@ -862,46 +861,45 @@ static DWORD SHNameTranslate(LPWSTR* wString, LPCWSTR* pWToFrom, BOOL more)
  */
 int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
 {
-	SHFILEOPSTRUCTW nFileOp = *((LPSHFILEOPSTRUCTW)lpFileOp);
-	int retCode = 0;
-	DWORD size;
-	LPWSTR ForFree = NULL, /* we change wString in SHNameTranslate and can't use it for freeing */
-	       wString = NULL; /* we change this in SHNameTranslate */
-
-	TRACE("\n");
-	if (FO_DELETE == (nFileOp.wFunc & FO_MASK))
-	  nFileOp.pTo = NULL; /* we need a NULL or a valid pointer for translation */
-	if (!(nFileOp.fFlags & FOF_SIMPLEPROGRESS))
-	  nFileOp.lpszProgressTitle = NULL; /* we need a NULL or a valid pointer for translation */
-	while (1) /* every loop calculate size, second translate also, if we have storage for this */
-	{
-	  size = SHNameTranslate(&wString, &nFileOp.lpszProgressTitle, FALSE); /* no loop */
-	  size += SHNameTranslate(&wString, &nFileOp.pFrom, TRUE); /* internal loop */
-	  size += SHNameTranslate(&wString, &nFileOp.pTo, TRUE); /* internal loop */
-
-	  if (ForFree)
-	  {
-	    retCode = SHFileOperationW(&nFileOp);
-	    /* Windows 95/98 returns S_OK for this case. */
-	    if (retCode == ERROR_ACCESS_DENIED && (GetVersion() & 0x80000000))
-	      retCode = S_OK;
-
-	    heap_free(ForFree); /* we cannot use wString, it was changed */
-	    break;
-	  }
-	  else
-	  {
-	    wString = ForFree = heap_alloc(size * sizeof(WCHAR));
-	    if (ForFree) continue;
-	    retCode = ERROR_OUTOFMEMORY;
-	    nFileOp.fAnyOperationsAborted = TRUE;
-	    return retCode;
-	  }
-	}
-
-	lpFileOp->hNameMappings = nFileOp.hNameMappings;
-	lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
-	return retCode;
+    SHFILEOPSTRUCTW nFileOp = *((LPSHFILEOPSTRUCTW)lpFileOp);
+    int retCode = 0;
+    DWORD size;
+    LPWSTR ForFree = NULL, /* we change wString in SHNameTranslate and can't use it for freeing */
+           wString = NULL; /* we change this in SHNameTranslate */
+
+    TRACE("\n");
+    if (FO_DELETE == (nFileOp.wFunc & FO_MASK))
+        nFileOp.pTo = NULL; /* we need a NULL or a valid pointer for translation */
+    if (!(nFileOp.fFlags & FOF_SIMPLEPROGRESS))
+        nFileOp.lpszProgressTitle = NULL; /* we need a NULL or a valid pointer for translation */
+    while (1) /* every loop calculate size, second translate also, if we have storage for this */
+    {
+        size = SHNameTranslate(&wString, &nFileOp.lpszProgressTitle, FALSE); /* no loop */
+        size += SHNameTranslate(&wString, &nFileOp.pFrom, TRUE); /* internal loop */
+        size += SHNameTranslate(&wString, &nFileOp.pTo, TRUE); /* internal loop */
+
+        if (ForFree)
+        {
+            retCode = SHFileOperationW(&nFileOp);
+            /* Windows 95/98 returns S_OK for this case. */
+            if (retCode == ERROR_ACCESS_DENIED && (GetVersion() & 0x80000000))
+                retCode = S_OK;
+            heap_free(ForFree); /* we cannot use wString, it was changed */
+            break;
+        }
+        else
+        {
+            wString = ForFree = heap_alloc(size * sizeof(WCHAR));
+            if (ForFree) continue;
+            retCode = ERROR_OUTOFMEMORY;
+            nFileOp.fAnyOperationsAborted = TRUE;
+            return retCode;
+        }
+    }
+
+    lpFileOp->hNameMappings = nFileOp.hNameMappings;
+    lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
+    return retCode;
 }
 
 #define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026
@@ -931,7 +929,7 @@ typedef struct
 static inline void grow_list(FILE_LIST *list)
 {
     FILE_ENTRY *new = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list->feFiles,
-                                  list->num_alloc * 2 * sizeof(*new) );
+    list->num_alloc * 2 * sizeof(*new) );
     list->feFiles = new;
     list->num_alloc *= 2;
 }
@@ -1024,7 +1022,7 @@ static HRESULT parse_file_list(FILE_LIST *flList, LPCWSTR szFiles)
     /* empty list */
     if (!szFiles[0])
         return ERROR_ACCESS_DENIED;
-        
+
     flList->feFiles = heap_alloc_zero(flList->num_alloc * sizeof(FILE_ENTRY));
 
     while (*ptr)
@@ -1129,7 +1127,7 @@ static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
     /* Don't ask the user about overwriting files when he accepted to overwrite the
        folder. FIXME: this is not exactly what Windows does - e.g. there would be
        an additional confirmation for a nested folder */
-    fileOp.fFlags |= FOF_NOCONFIRMATION;  
+    fileOp.fFlags |= FOF_NOCONFIRMATION;
 
     SHFileOperationW(&fileOp);
 }
@@ -1342,7 +1340,7 @@ static int delete_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom)
 
     /* Windows also checks only the first item */
     bTrash = (lpFileOp->fFlags & FOF_ALLOWUNDO)
-        && TRASH_CanTrashFile(flFrom->feFiles[0].szFullPath);
+             && TRASH_CanTrashFile(flFrom->feFiles[0].szFullPath);
 
     if (!(lpFileOp->fFlags & FOF_NOCONFIRMATION) || (!bTrash && lpFileOp->fFlags & FOF_WANTNUKEWARNING))
         if (!confirm_delete_list(lpFileOp->hwnd, lpFileOp->fFlags, bTrash, flFrom))
@@ -1377,11 +1375,11 @@ static int delete_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom)
                 break;
             }
         }
-        
+
         /* delete the file or directory */
         if (IsAttribFile(fileEntry->attributes))
             ret = DeleteFileW(fileEntry->szFullPath) ?
-                    ERROR_SUCCESS : GetLastError();
+                  ERROR_SUCCESS : GetLastError();
         else
             ret = SHELL_DeleteDirectoryW(lpFileOp->hwnd, fileEntry->szFullPath, FALSE);
 
@@ -1502,8 +1500,8 @@ static int rename_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, con
 static void check_flags(FILEOP_FLAGS fFlags)
 {
     WORD wUnsupportedFlags = FOF_NO_CONNECTED_ELEMENTS |
-        FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE |
-        FOF_RENAMEONCOLLISION | FOF_WANTMAPPINGHANDLE;
+                             FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE |
+                             FOF_RENAMEONCOLLISION | FOF_WANTMAPPINGHANDLE;
 
     if (fFlags & wUnsupportedFlags)
         FIXME("Unsupported flags: %04x\n", fFlags);
@@ -1586,19 +1584,19 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
  */
 void WINAPI SHFreeNameMappings(HANDLE hNameMapping)
 {
-	if (hNameMapping)
-	{
-	  int i = SHDSA_GetItemCount((HDSA)hNameMapping) - 1;
+    if (hNameMapping)
+    {
+        int i = SHDSA_GetItemCount((HDSA)hNameMapping) - 1;
 
-	  for (; i>= 0; i--)
-	  {
+        for (; i>= 0; i--)
+        {
             LPSHNAMEMAPPINGW lp = DSA_GetItemPtr(hNameMapping, i);
 
-	    SHFree(lp->pszOldPath);
-	    SHFree(lp->pszNewPath);
-	  }
-          DSA_Destroy(hNameMapping);
-	}
+            SHFree(lp->pszOldPath);
+            SHFree(lp->pszNewPath);
+        }
+        DSA_Destroy(hNameMapping);
+    }
 }
 
 /*************************************************************************
@@ -1704,14 +1702,14 @@ DWORD WINAPI SheChangeDirW(LPWSTR path)
 }
 
 /*************************************************************************
- * IsNetDrive			[SHELL32.66]
+ * IsNetDrive                   [SHELL32.66]
  */
 int WINAPI IsNetDrive(int drive)
 {
-	char root[4];
-	strcpy(root, "A:\\");
-	root[0] += (char)drive;
-	return (GetDriveTypeA(root) == DRIVE_REMOTE);
+    char root[4];
+    strcpy(root, "A:\\");
+    root[0] += (char)drive;
+    return (GetDriveTypeA(root) == DRIVE_REMOTE);
 }
 
 
-- 
2.17.0




More information about the wine-devel mailing list