Implemented localeconv() with libc function.
[wine.git] / dlls / shell32 / shlfileop.c
blobfd1c139309ffdaa3953159b8dff583510ac71580
1 /*
2 * SHFileOperation
4 * Copyright 2000 Juergen Schmied
5 * Copyright 2002 Andriy Palamarchuk
6 * Copyright 2002 Dietrich Teickner (from Odin)
7 * Copyright 2002 Rolf Kalbermatter
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <string.h>
28 #include <ctype.h>
30 #include "winreg.h"
31 #include "shellapi.h"
32 #include "shlobj.h"
33 #include "shresdef.h"
34 #define NO_SHLWAPI_STREAM
35 #include "shlwapi.h"
36 #include "shell32_main.h"
37 #include "undocshell.h"
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(shell);
43 #define IsAttribFile(x) (!(x == -1) && !(x & FILE_ATTRIBUTE_DIRECTORY))
44 #define IsAttribDir(x) (!(x == -1) && (x & FILE_ATTRIBUTE_DIRECTORY))
46 #define IsDotDir(x) ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))
48 #define FO_MASK 0xF
50 CHAR aWildcardFile[] = {'*','.','*',0};
51 WCHAR wWildcardFile[] = {'*','.','*',0};
52 WCHAR wWildcardChars[] = {'*','?',0};
53 WCHAR wBackslash[] = {'\\',0};
55 static BOOL SHNotifyCreateDirectoryA(LPCSTR path, LPSECURITY_ATTRIBUTES sec);
56 static BOOL SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec);
57 static BOOL SHNotifyRemoveDirectoryA(LPCSTR path);
58 static BOOL SHNotifyRemoveDirectoryW(LPCWSTR path);
59 static BOOL SHNotifyDeleteFileA(LPCSTR path);
60 static BOOL SHNotifyDeleteFileW(LPCWSTR path);
61 static BOOL SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest);
62 static BOOL SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bRenameIfExists);
64 typedef struct
66 UINT caption_resource_id, text_resource_id;
67 } SHELL_ConfirmIDstruc;
69 static BOOL SHELL_ConfirmIDs(int nKindOfDialog, SHELL_ConfirmIDstruc *ids)
71 switch (nKindOfDialog) {
72 case ASK_DELETE_FILE:
73 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
74 ids->text_resource_id = IDS_DELETEITEM_TEXT;
75 return TRUE;
76 case ASK_DELETE_FOLDER:
77 ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
78 ids->text_resource_id = IDS_DELETEITEM_TEXT;
79 return TRUE;
80 case ASK_DELETE_MULTIPLE_ITEM:
81 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
82 ids->text_resource_id = IDS_DELETEMULTIPLE_TEXT;
83 return TRUE;
84 case ASK_OVERWRITE_FILE:
85 ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION;
86 ids->text_resource_id = IDS_OVERWRITEFILE_TEXT;
87 return TRUE;
88 default:
89 FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog);
91 return FALSE;
94 BOOL SHELL_ConfirmDialog(int nKindOfDialog, LPCSTR szDir)
96 CHAR szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
97 SHELL_ConfirmIDstruc ids;
99 if (!SHELL_ConfirmIDs(nKindOfDialog, &ids))
100 return FALSE;
102 LoadStringA(shell32_hInstance, ids.caption_resource_id, szCaption, sizeof(szCaption));
103 LoadStringA(shell32_hInstance, ids.text_resource_id, szText, sizeof(szText));
105 FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
106 szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
108 return (IDOK == MessageBoxA(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
111 BOOL SHELL_ConfirmDialogW(int nKindOfDialog, LPCWSTR szDir)
113 WCHAR szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
114 SHELL_ConfirmIDstruc ids;
116 if (!SHELL_ConfirmIDs(nKindOfDialog, &ids))
117 return FALSE;
119 LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, sizeof(szCaption));
120 LoadStringW(shell32_hInstance, ids.text_resource_id, szText, sizeof(szText));
122 FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
123 szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
125 return (IDOK == MessageBoxW(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
128 /**************************************************************************
129 * SHELL_DeleteDirectoryA() [internal]
131 * like rm -r
133 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
135 BOOL ret = TRUE;
136 HANDLE hFind;
137 WIN32_FIND_DATAA wfd;
138 char szTemp[MAX_PATH];
140 /* Make sure the directory exists before eventually prompting the user */
141 PathCombineA(szTemp, pszDir, aWildcardFile);
142 hFind = FindFirstFileA(szTemp, &wfd);
143 if (hFind == INVALID_HANDLE_VALUE)
144 return FALSE;
146 if (!bShowUI || SHELL_ConfirmDialog(ASK_DELETE_FOLDER, pszDir))
150 LPSTR lp = wfd.cAlternateFileName;
151 if (!lp[0])
152 lp = wfd.cFileName;
153 if (IsDotDir(lp))
154 continue;
155 PathCombineA(szTemp, pszDir, lp);
156 if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
157 ret = SHELL_DeleteDirectoryA(szTemp, FALSE);
158 else
159 ret = SHNotifyDeleteFileA(szTemp);
160 } while (ret && FindNextFileA(hFind, &wfd));
162 FindClose(hFind);
163 if (ret)
164 ret = SHNotifyRemoveDirectoryA(pszDir);
165 return ret;
168 BOOL SHELL_DeleteDirectoryW(LPCWSTR pszDir, BOOL bShowUI)
170 BOOL ret = TRUE;
171 HANDLE hFind;
172 WIN32_FIND_DATAW wfd;
173 WCHAR szTemp[MAX_PATH];
175 /* Make sure the directory exists before eventually prompting the user */
176 PathCombineW(szTemp, pszDir, wWildcardFile);
177 hFind = FindFirstFileW(szTemp, &wfd);
178 if (hFind == INVALID_HANDLE_VALUE)
179 return FALSE;
181 if (!bShowUI || SHELL_ConfirmDialogW(ASK_DELETE_FOLDER, pszDir))
185 LPWSTR lp = wfd.cAlternateFileName;
186 if (!lp[0])
187 lp = wfd.cFileName;
188 if (IsDotDir(lp))
189 continue;
190 PathCombineW(szTemp, pszDir, lp);
191 if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
192 ret = SHELL_DeleteDirectoryW(szTemp, FALSE);
193 else
194 ret = SHNotifyDeleteFileW(szTemp);
195 } while (ret && FindNextFileW(hFind, &wfd));
197 FindClose(hFind);
198 if (ret)
199 ret = SHNotifyRemoveDirectoryW(pszDir);
200 return ret;
203 /**************************************************************************
204 * SHELL_DeleteFileA() [internal]
206 BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI)
208 if (bShowUI && !SHELL_ConfirmDialog(ASK_DELETE_FILE, pszFile))
209 return FALSE;
211 return SHNotifyDeleteFileA(pszFile);
214 BOOL SHELL_DeleteFileW(LPCWSTR pszFile, BOOL bShowUI)
216 if (bShowUI && !SHELL_ConfirmDialogW(ASK_DELETE_FILE, pszFile))
217 return FALSE;
219 return SHNotifyDeleteFileW(pszFile);
222 /**************************************************************************
223 * Win32CreateDirectory [SHELL32.93]
225 * Creates a directory. Also triggers a change notify if one exists.
227 * PARAMS
228 * path [I] path to directory to create
230 * RETURNS
231 * TRUE if successful, FALSE otherwise
233 * NOTES:
234 * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
235 * This is Unicode on NT/2000
237 static BOOL SHNotifyCreateDirectoryA(LPCSTR path, LPSECURITY_ATTRIBUTES sec)
239 BOOL ret;
240 TRACE("(%s, %p)\n", debugstr_a(path), sec);
242 ret = CreateDirectoryA(path, sec);
243 if (ret)
245 SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
247 return ret;
250 static BOOL SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
252 BOOL ret;
253 TRACE("(%s, %p)\n", debugstr_w(path), sec);
255 ret = CreateDirectoryW(path, sec);
256 if (ret)
258 SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL);
260 return ret;
263 BOOL WINAPI Win32CreateDirectoryAW(LPCVOID path, LPSECURITY_ATTRIBUTES sec)
265 if (SHELL_OsIsUnicode())
266 return SHNotifyCreateDirectoryW(path, sec);
267 return SHNotifyCreateDirectoryA(path, sec);
270 /************************************************************************
271 * Win32RemoveDirectory [SHELL32.94]
273 * Deletes a directory. Also triggers a change notify if one exists.
275 * PARAMS
276 * path [I] path to directory to delete
278 * RETURNS
279 * TRUE if successful, FALSE otherwise
281 * NOTES:
282 * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
283 * This is Unicode on NT/2000
285 static BOOL SHNotifyRemoveDirectoryA(LPCSTR path)
287 BOOL ret;
288 TRACE("(%s)\n", debugstr_a(path));
290 ret = RemoveDirectoryA(path);
291 if (!ret)
293 /* Directory may be write protected */
294 DWORD dwAttr = GetFileAttributesA(path);
295 if (dwAttr != -1 && dwAttr & FILE_ATTRIBUTE_READONLY)
296 if (SetFileAttributesA(path, dwAttr & ~FILE_ATTRIBUTE_READONLY))
297 ret = RemoveDirectoryA(path);
299 if (ret)
300 SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHA, path, NULL);
301 return ret;
304 static BOOL SHNotifyRemoveDirectoryW(LPCWSTR path)
306 BOOL ret;
307 TRACE("(%s)\n", debugstr_w(path));
309 ret = RemoveDirectoryW(path);
310 if (!ret)
312 /* Directory may be write protected */
313 DWORD dwAttr = GetFileAttributesW(path);
314 if (dwAttr != -1 && dwAttr & FILE_ATTRIBUTE_READONLY)
315 if (SetFileAttributesW(path, dwAttr & ~FILE_ATTRIBUTE_READONLY))
316 ret = RemoveDirectoryW(path);
318 if (ret)
319 SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, path, NULL);
320 return ret;
323 BOOL WINAPI Win32RemoveDirectoryAW(LPCVOID path)
325 if (SHELL_OsIsUnicode())
326 return SHNotifyRemoveDirectoryW(path);
327 return SHNotifyRemoveDirectoryA(path);
330 /************************************************************************
331 * Win32DeleteFile [SHELL32.164]
333 * Deletes a file. Also triggers a change notify if one exists.
335 * PARAMS
336 * path [I] path to file to delete
338 * RETURNS
339 * TRUE if successful, FALSE otherwise
341 * NOTES:
342 * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
343 * This is Unicode on NT/2000
345 static BOOL SHNotifyDeleteFileA(LPCSTR path)
347 BOOL ret;
349 TRACE("(%s)\n", debugstr_a(path));
351 ret = DeleteFileA(path);
352 if (!ret)
354 /* File may be write protected or a system file */
355 DWORD dwAttr = GetFileAttributesA(path);
356 if ((dwAttr != -1) && (dwAttr & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
357 if (SetFileAttributesA(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
358 ret = DeleteFileA(path);
360 if (ret)
361 SHChangeNotify(SHCNE_DELETE, SHCNF_PATHA, path, NULL);
362 return ret;
365 static BOOL SHNotifyDeleteFileW(LPCWSTR path)
367 BOOL ret;
369 TRACE("(%s)\n", debugstr_w(path));
371 ret = DeleteFileW(path);
372 if (!ret)
374 /* File may be write protected or a system file */
375 DWORD dwAttr = GetFileAttributesW(path);
376 if ((dwAttr != -1) && (dwAttr & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
377 if (SetFileAttributesW(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
378 ret = DeleteFileW(path);
380 if (ret)
381 SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, path, NULL);
382 return ret;
385 DWORD WINAPI Win32DeleteFileAW(LPCVOID path)
387 if (SHELL_OsIsUnicode())
388 return SHNotifyDeleteFileW(path);
389 return SHNotifyDeleteFileA(path);
392 /************************************************************************
393 * SHNotifyMoveFile [internal]
395 * Moves a file. Also triggers a change notify if one exists.
397 * PARAMS
398 * src [I] path to source file to move
399 * dest [I] path to target file to move to
401 * RETURNS
402 * TRUE if successful, FALSE otherwise
404 static BOOL SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest)
406 BOOL ret;
408 TRACE("(%s %s)\n", debugstr_w(src), debugstr_w(dest));
410 ret = MoveFileW(src, dest);
411 if (!ret)
413 /* Source file may be write protected or a system file */
414 DWORD dwAttr = GetFileAttributesW(src);
415 if ((dwAttr != -1) && (dwAttr & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
416 if (SetFileAttributesW(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
417 ret = MoveFileW(src, dest);
419 if (ret)
420 SHChangeNotify(SHCNE_RENAMEITEM, SHCNF_PATHW, src, dest);
421 return ret;
424 /************************************************************************
425 * SHNotifyCopyFile [internal]
427 * Copies a file. Also triggers a change notify if one exists.
429 * PARAMS
430 * src [I] path to source file to move
431 * dest [I] path to target file to move to
432 * bRename [I] if TRUE, the target file will be renamed if a
433 * file with this name already exists
435 * RETURNS
436 * TRUE if successful, FALSE otherwise
438 static BOOL SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bRename)
440 BOOL ret;
442 TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bRename ? "renameIfExists" : "");
444 ret = CopyFileW(src, dest, TRUE);
445 if (!ret && bRename)
447 /* Destination file probably exists */
448 DWORD dwAttr = GetFileAttributesW(dest);
449 if (dwAttr != -1)
451 FIXME("Rename on copy to existing file not implemented!");
454 if (ret)
455 SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, dest, NULL);
456 return ret;
459 /*************************************************************************
460 * SHCreateDirectory [SHELL32.165]
462 * Create a directory at the specified location
464 * PARAMS
465 * hWnd [I]
466 * path [I] path of directory to create
468 * RETURNS
469 * ERRROR_SUCCESS or one of the following values:
470 * ERROR_BAD_PATHNAME if the path is relative
471 * ERROR_FILE_EXISTS when a file with that name exists
472 * ERROR_ALREADY_EXISTS when the directory already exists
473 * ERROR_FILENAME_EXCED_RANGE if the filename was to long to process
475 * NOTES
476 * exported by ordinal
477 * Win9x exports ANSI
478 * WinNT/2000 exports Unicode
480 DWORD WINAPI SHCreateDirectory(HWND hWnd, LPCVOID path)
482 if (SHELL_OsIsUnicode())
483 return SHCreateDirectoryExW(hWnd, path, NULL);
484 return SHCreateDirectoryExA(hWnd, path, NULL);
487 /*************************************************************************
488 * SHCreateDirectoryExA [SHELL32.@]
490 * Create a directory at the specified location
492 * PARAMS
493 * hWnd [I]
494 * path [I] path of directory to create
495 * sec [I] security attributes to use or NULL
497 * RETURNS
498 * ERRROR_SUCCESS or one of the following values:
499 * ERROR_BAD_PATHNAME if the path is relative
500 * ERROR_FILE_EXISTS when a file with that name exists
501 * ERROR_ALREADY_EXISTS when the directory already exists
502 * ERROR_FILENAME_EXCED_RANGE if the filename was to long to process
504 DWORD WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec)
506 WCHAR wPath[MAX_PATH];
507 TRACE("(%p, %s, %p)\n",hWnd, debugstr_a(path), sec);
509 MultiByteToWideChar(CP_ACP, 0, path, -1, wPath, MAX_PATH);
510 return SHCreateDirectoryExW(hWnd, wPath, sec);
513 /*************************************************************************
514 * SHCreateDirectoryExW [SHELL32.@]
516 DWORD WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
518 DWORD ret = ERROR_SUCCESS;
519 TRACE("(%p, %s, %p)\n",hWnd, debugstr_w(path), sec);
521 if (PathIsRelativeW(path))
523 ret = ERROR_BAD_PATHNAME;
524 SetLastError(ERROR_BAD_PATHNAME);
526 else
528 if (!SHNotifyCreateDirectoryW(path, sec))
530 ret = GetLastError();
531 if (ret != ERROR_FILE_EXISTS &&
532 ret != ERROR_ALREADY_EXISTS &&
533 ret != ERROR_FILENAME_EXCED_RANGE)
535 /* handling network file names?
536 lstrcpynW(pathName, path, MAX_PATH);
537 lpStr = PathAddBackslashW(pathName);*/
538 FIXME("Semi-stub, non zero hWnd should be used somehow?");
542 return ret;
545 /*************************************************************************
547 * SHFileStrICmp HelperFunction for SHFileOperationW
550 BOOL SHFileStrICmpW(LPWSTR p1, LPWSTR p2, LPWSTR p1End, LPWSTR p2End)
552 WCHAR C1 = '\0';
553 WCHAR C2 = '\0';
554 int i_Temp = -1;
555 int i_len1 = lstrlenW(p1);
556 int i_len2 = lstrlenW(p2);
558 if (p1End && (&p1[i_len1] >= p1End) && ('\\' == p1End[0]))
560 C1 = p1End[0];
561 p1End[0] = '\0';
562 i_len1 = lstrlenW(p1);
564 if (p2End)
566 if ((&p2[i_len2] >= p2End) && ('\\' == p2End[0]))
568 C2 = p2End[0];
569 if (C2)
570 p2End[0] = '\0';
573 else
575 if ((i_len1 <= i_len2) && ('\\' == p2[i_len1]))
577 C2 = p2[i_len1];
578 if (C2)
579 p2[i_len1] = '\0';
582 i_len2 = lstrlenW(p2);
583 if (i_len1 == i_len2)
584 i_Temp = lstrcmpiW(p1,p2);
585 if (C1)
586 p1[i_len1] = C1;
587 if (C2)
588 p2[i_len2] = C2;
589 return !(i_Temp);
592 /*************************************************************************
594 * SHFileStrCpyCat HelperFunction for SHFileOperationW
597 LPWSTR SHFileStrCpyCatW(LPWSTR pTo, LPCWSTR pFrom, LPCWSTR pCatStr)
599 LPWSTR pToFile = NULL;
600 int i_len;
601 if (pTo)
603 if (pFrom)
604 lstrcpyW(pTo, pFrom);
605 if (pCatStr)
607 i_len = lstrlenW(pTo);
608 if ((i_len) && (pTo[--i_len] != '\\'))
609 i_len++;
610 pTo[i_len] = '\\';
611 if (pCatStr[0] == '\\')
612 pCatStr++; \
613 lstrcpyW(&pTo[i_len+1], pCatStr);
615 pToFile = StrRChrW(pTo,NULL,'\\');
616 /* termination of the new string-group */
617 pTo[(lstrlenW(pTo)) + 1] = '\0';
619 return pToFile;
622 /**************************************************************************
623 * SHELL_FileNamesMatch()
625 * Accepts two \0 delimited lists of the file names. Checks whether number of
626 * files in both lists is the same, and checks also if source-name exists.
628 BOOL SHELL_FileNamesMatch(LPCWSTR pszFiles1, LPCWSTR pszFiles2, BOOL bOnlySrc)
630 while ((pszFiles1[0] != '\0') &&
631 (bOnlySrc || (pszFiles2[0] != '\0')))
633 if (NULL == StrPBrkW(pszFiles1, wWildcardChars))
635 if (-1 == GetFileAttributesW(pszFiles1))
636 return FALSE;
638 pszFiles1 += lstrlenW(pszFiles1) + 1;
639 if (!bOnlySrc)
640 pszFiles2 += lstrlenW(pszFiles2) + 1;
642 return ((pszFiles1[0] == '\0') && (bOnlySrc || (pszFiles2[0] == '\0')));
645 /*************************************************************************
647 * SHNameTranslate HelperFunction for SHFileOperationA
649 * Translates a list of 0 terminated ASCII strings into Unicode. If *wString
650 * is NULL, only the necessary size of the string is determined and returned,
651 * otherwise the ASCII strings are copied into it and the buffer is increased
652 * to point to the location after the final 0 termination char.
654 DWORD SHNameTranslate(LPWSTR* wString, LPCWSTR* pWToFrom, BOOL more)
656 DWORD size = 0, aSize = 0;
657 LPCSTR aString = (LPCSTR)*pWToFrom;
659 if (aString)
663 size = lstrlenA(aString) + 1;
664 aSize += size;
665 aString += size;
666 } while ((size != 1) && more);
667 /* The two sizes might be different in the case of multibyte chars */
668 size = MultiByteToWideChar(CP_ACP, 0, aString, aSize, *wString, 0);
669 if (*wString) /* only in the second loop */
671 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, size);
672 *pWToFrom = *wString;
673 *wString += size;
676 return size;
678 /*************************************************************************
679 * SHFileOperationA [SHELL32.@]
681 * Function to copy, move, delete and create one or more files with optional
682 * user prompts.
684 * PARAMS
685 * lpFileOp [I/O] pointer to a structure containing all the necessary information
687 * NOTES
688 * exported by name
690 DWORD WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
692 SHFILEOPSTRUCTW nFileOp = *((LPSHFILEOPSTRUCTW)lpFileOp);
693 DWORD retCode = 0, size;
694 LPWSTR ForFree = NULL, /* we change wString in SHNameTranslate and can't use it for freeing */
695 wString = NULL; /* we change this in SHNameTranslate */
697 TRACE("\n");
698 if (FO_DELETE == (nFileOp.wFunc & FO_MASK))
699 nFileOp.pTo = NULL; /* we need a NULL or a valid pointer for translation */
700 if (!(nFileOp.fFlags & FOF_SIMPLEPROGRESS))
701 nFileOp.lpszProgressTitle = NULL; /* we need a NULL or a valid pointer for translation */
702 while (1) /* every loop calculate size, second translate also, if we have storage for this */
704 size = SHNameTranslate(&wString, &nFileOp.lpszProgressTitle, FALSE); /* no loop */
705 size += SHNameTranslate(&wString, &nFileOp.pFrom, TRUE); /* internal loop */
706 size += SHNameTranslate(&wString, &nFileOp.pTo, TRUE); /* internal loop */
708 if (ForFree)
710 retCode = SHFileOperationW(&nFileOp);
711 HeapFree(GetProcessHeap(), 0, ForFree); /* we can not use wString, it was changed */
712 break;
714 else
716 wString = ForFree = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
717 if (ForFree) continue;
718 retCode = ERROR_OUTOFMEMORY;
719 nFileOp.fAnyOperationsAborted = TRUE;
720 SetLastError(retCode);
721 return retCode;
725 lpFileOp->hNameMappings = nFileOp.hNameMappings;
726 lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
727 return retCode;
730 static const char * debug_shfileops_flags( DWORD fFlags )
732 return wine_dbg_sprintf( "%s%s%s%s%s%s%s%s%s%s%s%s%s",
733 fFlags & FOF_MULTIDESTFILES ? "FOF_MULTIDESTFILES " : "",
734 fFlags & FOF_CONFIRMMOUSE ? "FOF_CONFIRMMOUSE " : "",
735 fFlags & FOF_SILENT ? "FOF_SILENT " : "",
736 fFlags & FOF_RENAMEONCOLLISION ? "FOF_RENAMEONCOLLISION " : "",
737 fFlags & FOF_NOCONFIRMATION ? "FOF_NOCONFIRMATION " : "",
738 fFlags & FOF_WANTMAPPINGHANDLE ? "FOF_WANTMAPPINGHANDLE " : "",
739 fFlags & FOF_ALLOWUNDO ? "FOF_ALLOWUNDO " : "",
740 fFlags & FOF_FILESONLY ? "FOF_FILESONLY " : "",
741 fFlags & FOF_SIMPLEPROGRESS ? "FOF_SIMPLEPROGRESS " : "",
742 fFlags & FOF_NOCONFIRMMKDIR ? "FOF_NOCONFIRMMKDIR " : "",
743 fFlags & FOF_NOERRORUI ? "FOF_NOERRORUI " : "",
744 fFlags & FOF_NOCOPYSECURITYATTRIBS ? "FOF_NOCOPYSECURITYATTRIBS" : "",
745 fFlags & 0xf000 ? "MORE-UNKNOWN-Flags" : "");
748 static const char * debug_shfileops_action( DWORD op )
750 LPCSTR cFO_Name [] = {"FO_????","FO_MOVE","FO_COPY","FO_DELETE","FO_RENAME"};
751 return wine_dbg_sprintf("%s", cFO_Name[ op ]);
754 /*************************************************************************
755 * SHFileOperationW [SHELL32.@]
757 * See SHFileOperationA
759 DWORD WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
761 SHFILEOPSTRUCTW nFileOp = *(lpFileOp);
763 LPCWSTR pNextFrom = nFileOp.pFrom;
764 LPCWSTR pNextTo = nFileOp.pTo;
765 LPCWSTR pFrom = pNextFrom;
766 LPCWSTR pTo = NULL;
767 HANDLE hFind = INVALID_HANDLE_VALUE;
768 WIN32_FIND_DATAW wfd;
769 LPWSTR pTempFrom = NULL;
770 LPWSTR pTempTo = NULL;
771 LPWSTR pFromFile;
772 LPWSTR pToFile = NULL;
773 LPWSTR lpFileName;
774 long retCode = 0;
775 DWORD ToAttr;
776 DWORD ToPathAttr;
777 DWORD FromPathAttr;
778 FILEOP_FLAGS OFl = ((FILEOP_FLAGS)lpFileOp->fFlags & 0xfff);
780 BOOL b_Multi = (nFileOp.fFlags & FOF_MULTIDESTFILES);
782 BOOL b_MultiTo = (FO_DELETE != (lpFileOp->wFunc & FO_MASK));
783 BOOL b_MultiPaired = (!b_MultiTo);
784 BOOL b_MultiFrom = FALSE;
785 BOOL not_overwrite;
786 BOOL ask_overwrite;
787 BOOL b_SameRoot;
788 BOOL b_SameTailName;
789 BOOL b_ToInvalidTail = FALSE;
790 BOOL b_ToValid; /* for W98-Bug for FO_MOVE with source and target in same rootdrive */
791 BOOL b_Mask;
792 BOOL b_ToTailSlash = FALSE;
794 long FuncSwitch = (nFileOp.wFunc & FO_MASK);
795 long level= nFileOp.wFunc>>4;
797 /* default no error */
798 nFileOp.fAnyOperationsAborted = FALSE;
800 if ((FuncSwitch < FO_MOVE) || (FuncSwitch > FO_RENAME))
801 goto shfileop_normal; /* no valid FunctionCode */
803 if (level == 0)
804 TRACE("%s: flags (0x%04x) : %s\n",
805 debug_shfileops_action(FuncSwitch), nFileOp.fFlags,
806 debug_shfileops_flags(nFileOp.fFlags) );
808 /* establish when pTo is interpreted as the name of the destination file
809 * or the directory where the Fromfile should be copied to.
810 * This depends on:
811 * (1) pTo points to the name of an existing directory;
812 * (2) the flag FOF_MULTIDESTFILES is present;
813 * (3) whether pFrom point to multiple filenames.
815 * Some experiments:
817 * destisdir 1 1 1 1 0 0 0 0
818 * FOF_MULTIDESTFILES 1 1 0 0 1 1 0 0
819 * multiple from filenames 1 0 1 0 1 0 1 0
820 * ---------------
821 * copy files to dir 1 0 1 1 0 0 1 0
822 * create dir 0 0 0 0 0 0 1 0
825 * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY are implemented
826 * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR,
827 * FOF_SIMPLEPROGRESS, FOF_NOCOPYSECURITYATTRIBS are not implemented and ignored
828 * FOF_RENAMEONCOLLISION are implemented partially and breaks if file exist
829 * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE are not implemented and breaks
830 * if any other flag set, an error occurs
832 TRACE("%s level=%ld nFileOp.fFlags=0x%x\n",
833 debug_shfileops_action(FuncSwitch), level, lpFileOp->fFlags);
835 /* OFl &= (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY)); */
836 /* OFl ^= (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR); */
837 OFl &= (~(FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY)); /* implemented */
838 OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS); /* ignored, if one */
839 OFl &= (~FOF_SIMPLEPROGRESS); /* ignored, only with FOF_SILENT */
840 if (OFl)
842 if (OFl & (~(FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION |
843 FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS)))
845 TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n",
846 debug_shfileops_action(FuncSwitch), level, OFl);
847 retCode = 0x403; /* 1027, we need an extension to shlfileop */
848 goto shfileop_error;
850 else
852 TRACE("%s level=%ld lpFileOp->fFlags=0x%x not fully implemented, stub\n",
853 debug_shfileops_action(FuncSwitch), level, OFl);
854 } /* endif */
855 } /* endif */
857 if ((pNextFrom) && (!(b_MultiTo) || (pNextTo)))
859 nFileOp.pFrom = pTempFrom = HeapAlloc(GetProcessHeap(), 0, ((1 + 2 * (b_MultiTo)) * MAX_PATH + 6) * sizeof(WCHAR));
860 if (!pTempFrom)
862 retCode = ERROR_OUTOFMEMORY;
863 SetLastError(retCode);
864 goto shfileop_error;
866 if (b_MultiTo)
867 pTempTo = &pTempFrom[MAX_PATH + 4];
868 nFileOp.pTo = pTempTo;
869 ask_overwrite = (!(nFileOp.fFlags & FOF_NOCONFIRMATION) && !(nFileOp.fFlags & FOF_RENAMEONCOLLISION));
870 not_overwrite = (!(nFileOp.fFlags & FOF_NOCONFIRMATION) || (nFileOp.fFlags & FOF_RENAMEONCOLLISION));
872 else
874 retCode = 0x402; /* 1026 */
875 goto shfileop_error;
877 /* need break at error before change sourcepointer */
878 while(!nFileOp.fAnyOperationsAborted && (pNextFrom[0]))
880 nFileOp.wFunc = ((level + 1) << 4) + FuncSwitch;
881 nFileOp.fFlags = lpFileOp->fFlags;
883 if (b_MultiTo)
885 pTo = pNextTo;
886 pNextTo = &pNextTo[lstrlenW(pTo)+1];
887 b_MultiTo = (b_Multi && pNextTo[0]);
890 pFrom = pNextFrom;
891 pNextFrom = &pNextFrom[lstrlenW(pNextFrom)+1];
892 if (!b_MultiFrom && !b_MultiTo)
893 b_MultiFrom = (pNextFrom[0]);
895 pFromFile = SHFileStrCpyCatW(pTempFrom, pFrom, NULL);
897 if (pTo)
899 pToFile = SHFileStrCpyCatW(pTempTo, pTo, NULL);
901 if (!b_MultiPaired)
903 b_MultiPaired =
904 SHELL_FileNamesMatch(lpFileOp->pFrom, lpFileOp->pTo, (!b_Multi || b_MultiFrom));
905 } /* endif */
906 if (!(b_MultiPaired) || !(pFromFile) || !(pFromFile[1]) || ((pTo) && !(pToFile)))
908 retCode = 0x402; /* 1026 */
909 goto shfileop_error;
911 if (pTo)
913 b_ToTailSlash = (!pToFile[1]);
914 if (b_ToTailSlash)
916 pToFile[0] = '\0';
917 if (StrChrW(pTempTo,'\\'))
919 pToFile = SHFileStrCpyCatW(pTempTo, NULL, NULL);
922 b_ToInvalidTail = (NULL != StrPBrkW(&pToFile[1], wWildcardChars));
925 /* for all */
926 b_Mask = (NULL != StrPBrkW(&pFromFile[1], wWildcardChars));
927 if (FO_RENAME == FuncSwitch)
929 /* temporary only for FO_RENAME */
930 /* ??? b_Mask = (NULL != strrbrk(pFrom,"*?")); */
931 if (b_MultiTo || b_MultiFrom || (b_Mask && !b_ToInvalidTail))
933 /* no work, only RC=0 */
934 /* ??? nFileOp.fAnyOperationsAborted = TRUE; */
935 /*#define W98_FO_RENEME */
936 #ifdef W98_FO_RENEME
937 goto shfileop_normal;
938 #endif
939 retCode = 0x1; /* 1 value unknown, W98 returns no error */
940 goto shfileop_error;
944 hFind = FindFirstFileW(pFrom, &wfd);
945 if (INVALID_HANDLE_VALUE == hFind)
947 if ((FO_DELETE == FuncSwitch) && (b_Mask))
949 pFromFile[0] = '\0';
950 FromPathAttr = GetFileAttributesW(pTempFrom);
951 pFromFile[0] = '\\';
952 if (IsAttribDir(FromPathAttr))
954 /* FO_DELETE with mask and without found is valid */
955 goto shfileop_normal;
956 } /* endif */
957 } /* endif */
958 /* root (without mask) is also not allowed as source, tested in W98 */
959 retCode = 0x402; /* 1026 */
960 goto shfileop_error;
961 } /* endif */
963 /* for all */
964 #define HIGH_ADR (LPWSTR)0xffffffff
966 /* ??? b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); */
967 if (!pTo) /* FO_DELETE */
971 lpFileName = wfd.cAlternateFileName;
972 if (!lpFileName[0])
973 lpFileName = wfd.cFileName;
974 if (IsDotDir(lpFileName) ||
975 ((b_Mask) && IsAttribDir(wfd.dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
976 continue;
977 SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
978 /* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
979 if (IsAttribFile(wfd.dwFileAttributes))
981 nFileOp.fAnyOperationsAborted = (!SHNotifyDeleteFileW(pTempFrom));
982 retCode = 0x78; /* value unknown */
984 else
986 nFileOp.fAnyOperationsAborted = (!SHELL_DeleteDirectoryW(pTempFrom, (!(nFileOp.fFlags & FOF_NOCONFIRMATION))));
987 retCode = 0x79; /* value unknown */
989 } while (!nFileOp.fAnyOperationsAborted && FindNextFileW(hFind, &wfd));
990 FindClose(hFind);
991 hFind = INVALID_HANDLE_VALUE;
992 if (nFileOp.fAnyOperationsAborted)
994 goto shfileop_error;
996 continue;
997 } /* FO_DELETE ends, pTo must be always valid from here */
999 b_SameRoot = (toupperW(pTempFrom[0]) == toupperW(pTempTo[0]));
1000 b_SameTailName = SHFileStrICmpW(pToFile, pFromFile, NULL, NULL);
1002 ToPathAttr = ToAttr = GetFileAttributesW(pTempTo);
1003 if (!b_Mask && (ToAttr == -1) && (pToFile))
1005 pToFile[0] = '\0';
1006 ToPathAttr = GetFileAttributesW(pTempTo);
1007 pToFile[0] = '\\';
1010 if (FO_RENAME == FuncSwitch)
1012 if (!b_SameRoot || b_Mask /* FO_RENAME works not with Mask */
1013 || !SHFileStrICmpW(pTempFrom, pTempTo, pFromFile, NULL)
1014 || (SHFileStrICmpW(pTempFrom, pTempTo, pFromFile, HIGH_ADR) && !b_ToTailSlash))
1016 retCode = 0x73;
1017 goto shfileop_error;
1019 if (b_ToInvalidTail)
1021 retCode=0x2;
1022 goto shfileop_error;
1024 if (-1 == ToPathAttr)
1026 retCode = 0x75;
1027 goto shfileop_error;
1029 if (IsAttribDir(wfd.dwFileAttributes) && IsAttribDir(ToAttr))
1031 retCode = (b_ToTailSlash) ? 0xb7 : 0x7b;
1032 goto shfileop_error;
1033 } /* endif */
1034 /* we use SHNotifyMoveFile() instead MoveFileW */
1035 if (!SHNotifyMoveFileW(pTempFrom, pTempTo))
1037 /* we need still the value for the returncode, we use the mostly assumed */
1038 retCode = 0xb7;
1039 goto shfileop_error;
1041 goto shfileop_normal;
1044 /* W98 Bug with FO_MOVE different to FO_COPY, better the same as FO_COPY */
1045 b_ToValid = ((b_SameTailName && b_SameRoot && (FO_COPY == FuncSwitch)) ||
1046 (b_SameTailName && !b_SameRoot) || (b_ToInvalidTail));
1048 /* handle mask in source */
1049 if (b_Mask)
1051 if (!IsAttribDir(ToAttr))
1053 retCode = (b_ToInvalidTail &&/* b_SameTailName &&*/ (FO_MOVE == FuncSwitch)) \
1054 ? 0x2 : 0x75;
1055 goto shfileop_error;
1057 pToFile = SHFileStrCpyCatW(pTempTo, NULL, wBackslash);
1058 nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES);
1061 lpFileName = wfd.cAlternateFileName;
1062 if (!lpFileName[0])
1063 lpFileName = wfd.cFileName;
1064 if (IsDotDir(lpFileName) ||
1065 (IsAttribDir(wfd.dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
1066 continue; /* next name in pTempFrom(dir) */
1067 SHFileStrCpyCatW(&pToFile[1], lpFileName, NULL);
1068 SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
1069 retCode = SHFileOperationW (&nFileOp);
1070 } while(!nFileOp.fAnyOperationsAborted && FindNextFileW(hFind, &wfd));
1072 FindClose(hFind);
1073 hFind = INVALID_HANDLE_VALUE;
1074 /* FO_COPY/FO_MOVE with mask, FO_DELETE and FO_RENAME are solved */
1075 if (b_Mask)
1076 continue;
1078 /* only FO_COPY/FO_MOVE without mask, all others are (must be) solved */
1079 if (IsAttribDir(wfd.dwFileAttributes) && (ToAttr == -1))
1081 if (pToFile)
1083 pToFile[0] = '\0';
1084 ToPathAttr = GetFileAttributesW(pTempTo);
1085 if ((ToPathAttr == -1) && b_ToValid)
1087 /* create dir must be here, sample target D:\y\ *.* create with RC=10003 */
1088 if (SHCreateDirectoryExW(NULL, pTempTo, NULL))
1090 retCode = 0x73;/* value unknown */
1091 goto shfileop_error;
1093 ToPathAttr = GetFileAttributesW(pTempTo);
1095 pToFile[0] = '\\';
1096 if (b_ToInvalidTail)
1098 retCode = 0x10003;
1099 goto shfileop_error;
1104 /* trailing BackSlash is ever removed and pToFile points to BackSlash before */
1105 if (!b_MultiTo && (b_MultiFrom || (!(b_Multi) && IsAttribDir(ToAttr))))
1107 if ((FO_MOVE == FuncSwitch) && IsAttribDir(ToAttr) && IsAttribDir(wfd.dwFileAttributes))
1109 if (b_Multi)
1111 retCode = 0x73; /* !b_Multi = 0x8 ?? */
1112 goto shfileop_error;
1115 pToFile = SHFileStrCpyCatW(pTempTo, NULL, wfd.cFileName);
1116 ToAttr = GetFileAttributesW(pTempTo);
1119 if (IsAttribDir(ToAttr))
1121 if (IsAttribFile(wfd.dwFileAttributes))
1123 retCode = (FO_COPY == FuncSwitch) ? 0x75 : 0xb7;
1124 goto shfileop_error;
1127 else
1129 pToFile[0] = '\0';
1130 ToPathAttr = GetFileAttributesW(pTempTo);
1131 pToFile[0] = '\\';
1132 if (IsAttribFile(ToPathAttr))
1134 /* error, is this tested ? */
1135 retCode = 0x777402;
1136 goto shfileop_error;
1137 } /* endif */
1140 /* singlesource + no mask */
1141 if (-1 == (ToAttr & ToPathAttr))
1143 /* Target-dir does not exist, and cannot be created */
1144 retCode=0x75;
1145 goto shfileop_error;
1148 switch(FuncSwitch)
1150 case FO_MOVE:
1151 pToFile = NULL;
1152 if ((ToAttr == -1) && SHFileStrICmpW(pTempFrom, pTempTo, pFromFile, NULL))
1154 nFileOp.wFunc = ((level+1)<<4) + FO_RENAME;
1156 else
1158 if (b_SameRoot && IsAttribDir(ToAttr) && IsAttribDir(wfd.dwFileAttributes))
1160 /* we need pToFile for FO_DELETE after FO_MOVE contence */
1161 pToFile = SHFileStrCpyCatW(pTempFrom, NULL, wWildcardFile);
1163 else
1165 nFileOp.wFunc = ((level+1)<<4) + FO_COPY;
1168 retCode = SHFileOperationW(&nFileOp);
1169 if (pToFile)
1170 ((DWORD*)pToFile)[0] = '\0';
1171 if (!nFileOp.fAnyOperationsAborted && (FO_RENAME != (nFileOp.wFunc & 0xf)))
1173 nFileOp.wFunc = ((level+1)<<4) + FO_DELETE;
1174 retCode = SHFileOperationW(&nFileOp);
1176 continue;
1177 case FO_COPY:
1178 if (SHFileStrICmpW(pTempFrom, pTempTo, NULL, NULL))
1179 { /* target is the same as source ? */
1180 /* we still need the value for the returncode, we assume 0x71 */
1181 retCode = 0x71;
1182 goto shfileop_error;
1183 } /* endif */
1184 if (IsAttribDir((ToAttr & wfd.dwFileAttributes)))
1186 if (IsAttribDir(ToAttr) || !SHCreateDirectoryExW(NULL,pTempTo, NULL))
1188 /* ??? nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES); */
1189 SHFileStrCpyCatW(pTempFrom, NULL, wWildcardFile);
1190 retCode = SHFileOperationW(&nFileOp);
1192 else
1194 retCode = 0x750;/* value unknown */
1195 goto shfileop_error;
1198 else
1200 if (!(ask_overwrite && SHELL_ConfirmDialogW(ASK_OVERWRITE_FILE, pTempTo))
1201 && (not_overwrite))
1203 /* we still need the value for the returncode, we use the mostly assumed */
1204 retCode = 0x73;
1205 goto shfileop_error;
1207 if (!(SHNotifyCopyFileW(pTempFrom, pTempTo, nFileOp.fFlags & FOF_RENAMEONCOLLISION)))
1209 retCode = 0x77; /* value unknown */
1210 goto shfileop_error;
1213 } /* end-switch */
1214 } /* end-while */
1216 shfileop_normal:
1217 if (!(nFileOp.fAnyOperationsAborted))
1218 retCode = 0;
1219 shfileop_error:
1220 if (hFind != INVALID_HANDLE_VALUE)
1221 FindClose(hFind);
1222 hFind = INVALID_HANDLE_VALUE;
1223 if (pTempFrom)
1224 HeapFree(GetProcessHeap(), 0, pTempFrom);
1225 if (retCode)
1227 nFileOp.fAnyOperationsAborted = TRUE;
1229 TRACE("%s level=%ld AnyOpsAborted=%s ret=0x%lx, with %s %s%s\n",
1230 debug_shfileops_action(FuncSwitch), level,
1231 nFileOp.fAnyOperationsAborted ? "TRUE":"FALSE",
1232 retCode, debugstr_w(pFrom), pTo ? "-> ":"", debugstr_w(pTo));
1234 lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
1235 return retCode;
1238 /*************************************************************************
1239 * SHFileOperation [SHELL32.@]
1242 DWORD WINAPI SHFileOperationAW(LPVOID lpFileOp)
1244 if (SHELL_OsIsUnicode())
1245 return SHFileOperationW(lpFileOp);
1246 return SHFileOperationA(lpFileOp);
1249 /*************************************************************************
1250 * SheGetDirW [SHELL32.281]
1253 HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
1254 { FIXME("%p %p stub\n",u,v);
1255 return 0;
1258 /*************************************************************************
1259 * SheChangeDirW [SHELL32.274]
1262 HRESULT WINAPI SheChangeDirW(LPWSTR u)
1263 { FIXME("(%s),stub\n",debugstr_w(u));
1264 return 0;
1267 /*************************************************************************
1268 * IsNetDrive [SHELL32.66]
1270 BOOL WINAPI IsNetDrive(DWORD drive)
1272 char root[4];
1273 strcpy(root, "A:\\");
1274 root[0] += (char)drive;
1275 return (GetDriveTypeA(root) == DRIVE_REMOTE);