ReactOS 0.4.16-dev-41-ge8c7597
shlfileop.cpp File Reference
#include "precomp.h"
Include dependency graph for shlfileop.cpp:

Go to the source code of this file.

Classes

struct  FILE_OPERATION
 
struct  FILE_ENTRY
 
struct  FILE_LIST
 
struct  confirm_msg_info
 
struct  SHELL_ConfirmIDstruc
 

Macros

#define IsAttrib(x, y)   ((INVALID_FILE_ATTRIBUTES != (x)) && ((x) & (y)))
 
#define IsAttribFile(x)   (!((x) & FILE_ATTRIBUTE_DIRECTORY))
 
#define IsAttribDir(x)   IsAttrib(x, FILE_ATTRIBUTE_DIRECTORY)
 
#define IsDotDir(x)   ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))
 
#define FO_MASK   0xF
 
#define NEW_FILENAME_ON_COPY_TRIES   100
 
#define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND   1026
 
#define GET_FILENAME(fe)   ((fe)->szFilename[0] ? (fe)->szFilename : (fe)->szFullPath)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static DWORD SHNotifyCreateDirectoryW (LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
 
static DWORD SHNotifyRemoveDirectoryW (LPCWSTR path)
 
static DWORD SHNotifyDeleteFileW (FILE_OPERATION *op, LPCWSTR path)
 
static DWORD SHNotifyMoveFileW (FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest, BOOL isdir)
 
static DWORD SHNotifyCopyFileW (FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
 
static DWORD SHFindAttrW (LPCWSTR pName, BOOL fileOnly)
 
static HRESULT copy_files (FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flFrom, FILE_LIST *flTo)
 
static DWORD move_files (FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flFrom, const FILE_LIST *flTo)
 
DWORD WINAPI _FileOpCountManager (FILE_OPERATION *op, const FILE_LIST *flFrom)
 
static BOOL _FileOpCount (FILE_OPERATION *op, LPWSTR pwszBuf, BOOL bFolder, DWORD *ticks)
 
static void confirm_msg_move_button (HWND hDlg, INT iId, INT *xPos, INT yOffset, BOOL bShow)
 
static INT_PTR ConfirmMsgBox_Paint (HWND hDlg)
 
static INT_PTR ConfirmMsgBox_Init (HWND hDlg, LPARAM lParam)
 
static INT_PTR CALLBACK ConfirmMsgBoxProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
int SHELL_ConfirmMsgBox (HWND hWnd, LPWSTR lpszText, LPWSTR lpszCaption, HICON hIcon, BOOL bYesToAll)
 
static BOOL SHELL_ConfirmIDs (int nKindOfDialog, SHELL_ConfirmIDstruc *ids)
 
static BOOL SHELL_ConfirmDialogW (HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FILE_OPERATION *op)
 
BOOL SHELL_ConfirmYesNoW (HWND hWnd, int nKindOfDialog, LPCWSTR szDir)
 
static DWORD SHELL32_AnsiToUnicodeBuf (LPCSTR aPath, LPWSTR *wPath, DWORD minChars)
 
static void SHELL32_FreeUnicodeBuf (LPWSTR wPath)
 
EXTERN_C HRESULT WINAPI SHIsFileAvailableOffline (LPCWSTR path, LPDWORD status)
 
BOOL SHELL_DeleteDirectoryW (FILE_OPERATION *op, LPCWSTR pszDir, BOOL bShowUI)
 
EXTERN_C BOOL WINAPI Win32CreateDirectoryW (LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
 
EXTERN_C BOOL WINAPI Win32RemoveDirectoryW (LPCWSTR path)
 
static void _SetOperationTitle (FILE_OPERATION *op)
 
static void _SetOperationTexts (FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest)
 
DWORD CALLBACK SHCopyProgressRoutine (LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData)
 
EXTERN_C DWORD WINAPI Win32DeleteFileW (LPCWSTR path)
 
static DWORD CheckForError (FILE_OPERATION *op, DWORD error, LPCWSTR src)
 
static BOOL SHIsCdRom (LPCWSTR path)
 
int WINAPI SHCreateDirectory (HWND hWnd, LPCWSTR path)
 
int WINAPI SHCreateDirectoryExA (HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec)
 
int WINAPI SHCreateDirectoryExW (HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
 
static DWORD _ConvertAtoW (PCSTR strSrc, PCWSTR *pStrDest, BOOL isList)
 
int WINAPI SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp)
 
static void __inline grow_list (FILE_LIST *list)
 
static void add_file_to_entry (FILE_ENTRY *feFile, LPCWSTR szFile)
 
static LPWSTR wildcard_to_file (LPCWSTR szWildCard, LPCWSTR szFileName)
 
static void parse_wildcard_files (FILE_LIST *flList, LPCWSTR szFile, LPDWORD pdwListIndex)
 
static HRESULT parse_file_list (FILE_LIST *flList, LPCWSTR szFiles)
 
static void destroy_file_list (FILE_LIST *flList)
 
static CStringW try_find_new_name (LPCWSTR szDestPath)
 
static void copy_dir_to_dir (FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWSTR szDestPath)
 
static BOOL copy_file_to_file (FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
 
static void copy_to_dir (FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo)
 
static void create_dest_dirs (LPCWSTR szDestDir)
 
static BOOL confirm_delete_list (HWND hWnd, DWORD fFlags, BOOL fTrash, const FILE_LIST *flFrom)
 
static HRESULT delete_files (FILE_OPERATION *op, const FILE_LIST *flFrom)
 
static void move_dir_to_dir (FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWSTR szDestPath)
 
static BOOL move_file_to_file (FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
 
static void move_to_dir (FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo)
 
static HRESULT rename_files (FILE_OPERATION *op, const FILE_LIST *flFrom, const FILE_LIST *flTo)
 
static void check_flags (FILEOP_FLAGS fFlags)
 
static DWORD validate_operation (LPSHFILEOPSTRUCTW lpFileOp, FILE_LIST *flFrom, FILE_LIST *flTo)
 
int WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)
 
static int CALLBACK _DestroyCallback (void *p, void *pData)
 
void WINAPI SHFreeNameMappings (HANDLE hNameMapping)
 
EXTERN_C DWORD WINAPI SheGetDirA (DWORD drive, LPSTR buffer)
 
EXTERN_C DWORD WINAPI SheGetDirW (DWORD drive, LPWSTR buffer)
 
EXTERN_C DWORD WINAPI SheChangeDirA (LPSTR path)
 
EXTERN_C DWORD WINAPI SheChangeDirW (LPWSTR path)
 
EXTERN_C int WINAPI IsNetDrive (int drive)
 
EXTERN_C INT WINAPI RealDriveType (INT drive, BOOL bQueryNet)
 
EXTERN_C HRESULT WINAPI SHPathPrepareForWriteW (HWND hwnd, IUnknown *modless, LPCWSTR path, DWORD flags)
 
EXTERN_C HRESULT WINAPI SHPathPrepareForWriteA (HWND hwnd, IUnknown *modless, LPCSTR path, DWORD flags)
 

Macro Definition Documentation

◆ ERROR_SHELL_INTERNAL_FILE_NOT_FOUND

#define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND   1026

Definition at line 50 of file shlfileop.cpp.

◆ FO_MASK

#define FO_MASK   0xF

Definition at line 34 of file shlfileop.cpp.

◆ GET_FILENAME

#define GET_FILENAME (   fe)    ((fe)->szFilename[0] ? (fe)->szFilename : (fe)->szFullPath)

Definition at line 1887 of file shlfileop.cpp.

◆ IsAttrib

#define IsAttrib (   x,
  y 
)    ((INVALID_FILE_ATTRIBUTES != (x)) && ((x) & (y)))

Definition at line 29 of file shlfileop.cpp.

◆ IsAttribDir

#define IsAttribDir (   x)    IsAttrib(x, FILE_ATTRIBUTE_DIRECTORY)

Definition at line 31 of file shlfileop.cpp.

◆ IsAttribFile

#define IsAttribFile (   x)    (!((x) & FILE_ATTRIBUTE_DIRECTORY))

Definition at line 30 of file shlfileop.cpp.

◆ IsDotDir

#define IsDotDir (   x)    ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))))

Definition at line 32 of file shlfileop.cpp.

◆ NEW_FILENAME_ON_COPY_TRIES

#define NEW_FILENAME_ON_COPY_TRIES   100

Definition at line 36 of file shlfileop.cpp.

Function Documentation

◆ _ConvertAtoW()

static DWORD _ConvertAtoW ( PCSTR  strSrc,
PCWSTR pStrDest,
BOOL  isList 
)
static

Definition at line 998 of file shlfileop.cpp.

999{
1000 *pStrDest = NULL;
1001
1002 // If the input is null, nothing to convert.
1003 if (!strSrc)
1004 return 0;
1005
1006 // Measure the total size, depending on if it's a zero-terminated list.
1007 int sizeA = 0;
1008 if (isList)
1009 {
1010 PCSTR tmpSrc = strSrc;
1011 int size;
1012 do
1013 {
1014 size = lstrlenA(tmpSrc) + 1;
1015 sizeA += size;
1016 tmpSrc += size;
1017 } while (size != 1);
1018 }
1019 else
1020 {
1021 sizeA = lstrlenA(strSrc) + 1;
1022 }
1023
1024 // Measure the needed allocation size.
1025 int sizeW = MultiByteToWideChar(CP_ACP, 0, strSrc, sizeA, NULL, 0);
1026 if (!sizeW)
1027 return GetLastError();
1028
1029 PWSTR strDest = (PWSTR) HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
1030 if (!strDest)
1031 return ERROR_OUTOFMEMORY;
1032
1033 int err = MultiByteToWideChar(CP_ACP, 0, strSrc, sizeA, strDest, sizeW);
1034 if (!err)
1035 {
1036 HeapFree(GetProcessHeap(), 0, strDest);
1037 return GetLastError();
1038 }
1039
1040 *pStrDest = strDest;
1041 return 0;
1042}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
static const WCHAR sizeW[]
Definition: editor.c:79
GLsizeiptr size
Definition: glext.h:5919
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define err(...)
uint16_t * PWSTR
Definition: typedefs.h:56
const char * PCSTR
Definition: typedefs.h:52
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by SHFileOperationA().

◆ _DestroyCallback()

static int CALLBACK _DestroyCallback ( void p,
void pData 
)
static

Definition at line 2077 of file shlfileop.cpp.

2078{
2080
2081 SHFree(lp->pszOldPath);
2082 SHFree(lp->pszNewPath);
2083
2084 return TRUE;
2085}
#define TRUE
Definition: types.h:120
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
GLfloat GLfloat p
Definition: glext.h:8902
LPWSTR pszOldPath
Definition: shellapi.h:390
LPWSTR pszNewPath
Definition: shellapi.h:391

Referenced by SHFreeNameMappings().

◆ _FileOpCount()

static BOOL _FileOpCount ( FILE_OPERATION op,
LPWSTR  pwszBuf,
BOOL  bFolder,
DWORD ticks 
)
static

Definition at line 2331 of file shlfileop.cpp.

2332{
2333 /* Find filename position */
2334 UINT cchBuf = wcslen(pwszBuf);
2335 WCHAR *pwszFilename = pwszBuf + cchBuf;
2336 size_t cchFilenameMax = MAX_PATH - cchBuf;
2337 if (!cchFilenameMax)
2338 return FALSE;
2339
2340 if (bFolder) {
2341 *(pwszFilename++) = '\\';
2342 --cchFilenameMax;
2343 /* Find all files, FIXME: shouldn't be "*"? */
2344 StringCchCopyW(pwszFilename, cchFilenameMax, L"*");
2345 }
2346
2347 WIN32_FIND_DATAW wfd;
2348 HANDLE hFind = FindFirstFileW(pwszBuf, &wfd);
2349 if (hFind == INVALID_HANDLE_VALUE)
2350 {
2351 ERR("FindFirstFileW %ls failed\n", pwszBuf);
2352 return FALSE;
2353 }
2354
2355 do
2356 {
2357 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
2358 {
2359 /* Don't process "." and ".." items */
2360 if (!wcscmp(wfd.cFileName, L".") || !wcscmp(wfd.cFileName, L".."))
2361 continue;
2362
2363 StringCchCopyW(pwszFilename, cchFilenameMax, wfd.cFileName);
2364 _FileOpCount(op, pwszBuf, TRUE, ticks);
2365 }
2366 else
2367 {
2369 FileSize.u.LowPart = wfd.nFileSizeLow;
2370 FileSize.u.HighPart = wfd.nFileSizeHigh;
2371 op->totalSize.QuadPart += FileSize.QuadPart;
2372 }
2373 if (GetTickCount() - *ticks > (DWORD) 500)
2374 {
2375 // Check if the dialog has ended. If it has, we'll spin down.
2376 if (op->progress != NULL)
2377 op->bCancelled = op->progress->HasUserCancelled();
2378
2379 if (op->bCancelled)
2380 break;
2381 *ticks = GetTickCount();
2382 }
2383 } while(FindNextFileW(hFind, &wfd));
2384
2385 FindClose(hFind);
2386 return TRUE;
2387}
#define ERR(fmt,...)
Definition: precomp.h:57
#define FALSE
Definition: types.h:117
UINT op
Definition: effect.c:236
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int UINT
Definition: ndis.h:50
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static BOOL _FileOpCount(FILE_OPERATION *op, LPWSTR pwszBuf, BOOL bFolder, DWORD *ticks)
Definition: shlfileop.cpp:2331
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2299 u

Referenced by _FileOpCount(), and _FileOpCountManager().

◆ _FileOpCountManager()

DWORD WINAPI _FileOpCountManager ( FILE_OPERATION op,
const FILE_LIST flFrom 
)

Definition at line 2313 of file shlfileop.cpp.

2314{
2315 DWORD ticks = GetTickCount();
2316 FILE_ENTRY *entryToCount;
2317
2318 for (UINT i = 0; i < from->dwNumFiles; i++)
2319 {
2320 entryToCount = &from->feFiles[i];
2321
2322 WCHAR theFileName[MAX_PATH];
2323 StringCchCopyW(theFileName, MAX_PATH, entryToCount->szFullPath);
2324 _FileOpCount(op, theFileName, IsAttribDir(entryToCount->attributes), &ticks);
2325 }
2326 return 0;
2327}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IsAttribDir(x)
Definition: shlfileop.cpp:31
CardRegion * from
Definition: spigame.cpp:19
Definition: shlfileop.cpp:53
DWORD attributes
Definition: shlfileop.cpp:54
LPWSTR szFullPath
Definition: shlfileop.cpp:57

Referenced by SHFileOperationW().

◆ _SetOperationTexts()

static void _SetOperationTexts ( FILE_OPERATION op,
LPCWSTR  src,
LPCWSTR  dest 
)
static

Definition at line 509 of file shlfileop.cpp.

509 {
510 if (op->progress == NULL || src == NULL)
511 return;
512 LPWSTR fileSpecS, pathSpecS, fileSpecD, pathSpecD;
513 WCHAR szFolderS[50], szFolderD[50], szFinalString[260];
514
515 DWORD_PTR args[2];
516
517 fileSpecS = (pathSpecS = (LPWSTR) src);
518 fileSpecD = (pathSpecD = (LPWSTR) dest);
519
520 // March across the string to get the file path and it's parent dir.
521 for (LPWSTR ptr = (LPWSTR) src; *ptr; ptr++) {
522 if (*ptr == '\\') {
523 pathSpecS = fileSpecS;
524 fileSpecS = ptr+1;
525 }
526 }
527 lstrcpynW(szFolderS, pathSpecS, min(50, fileSpecS - pathSpecS));
528 args[0] = (DWORD_PTR) szFolderS;
529
530 switch (op->req->wFunc)
531 {
532 case FO_COPY:
533 case FO_MOVE:
534 if (dest == NULL)
535 return;
536 for (LPWSTR ptr = (LPWSTR) dest; *ptr; ptr++) {
537 if (*ptr == '\\') {
538 pathSpecD = fileSpecD;
539 fileSpecD = ptr + 1;
540 }
541 }
542 lstrcpynW(szFolderD, pathSpecD, min(50, fileSpecD - pathSpecD));
543 args[1] = (DWORD_PTR) szFolderD;
544 break;
545 case FO_DELETE:
546 break;
547 default:
548 return;
549 }
550
552 op->szBuilderString, 0, 0, szFinalString, sizeof(szFinalString), (va_list*)args);
553
554 op->progress->SetLine(1, fileSpecS, false, NULL);
555 op->progress->SetLine(2, szFinalString, false, NULL);
556}
char * va_list
Definition: acmsvcex.h:78
#define lstrcpynW
Definition: compat.h:738
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
GLenum src
Definition: glext.h:6340
static PVOID ptr
Definition: dispmode.c:27
static char * dest
Definition: rtl.c:135
#define min(a, b)
Definition: monoChain.cc:55
#define FO_DELETE
Definition: shellapi.h:138
#define FO_COPY
Definition: shellapi.h:137
#define FO_MOVE
Definition: shellapi.h:136
Definition: match.c:390
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:421
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:424
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by SHNotifyCopyFileW(), SHNotifyDeleteFileW(), and SHNotifyMoveFileW().

◆ _SetOperationTitle()

static void _SetOperationTitle ( FILE_OPERATION op)
static

Definition at line 476 of file shlfileop.cpp.

476 {
477 if (op->progress == NULL)
478 return;
479 WCHAR szTitle[50], szPreflight[50];
480 UINT animation_id = NULL;
481
482 switch (op->req->wFunc)
483 {
484 case FO_COPY:
486 LoadStringW(shell32_hInstance, IDS_FILEOOP_FROM_TO, op->szBuilderString, sizeof( op->szBuilderString)/sizeof(WCHAR));
487 animation_id = IDA_SHELL_COPY;
488 break;
489 case FO_DELETE:
491 LoadStringW(shell32_hInstance, IDS_FILEOOP_FROM, op->szBuilderString, sizeof( op->szBuilderString)/sizeof(WCHAR));
492 animation_id = IDA_SHELL_DELETE;
493 break;
494 case FO_MOVE:
496 LoadStringW(shell32_hInstance, IDS_FILEOOP_FROM_TO, op->szBuilderString, sizeof( op->szBuilderString)/sizeof(WCHAR));
497 animation_id = IDA_SHELL_COPY;
498 break;
499 default:
500 return;
501 }
502 LoadStringW(shell32_hInstance, IDS_FILEOOP_PREFLIGHT, szPreflight, sizeof(szPreflight)/sizeof(WCHAR));
503
504 op->progress->SetTitle(szTitle);
505 op->progress->SetLine(1, szPreflight, false, NULL);
506 op->progress->SetAnimation(shell32_hInstance, animation_id);
507}
#define shell32_hInstance
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define IDA_SHELL_DELETE
Definition: shresdef.h:812
#define IDS_FILEOOP_FROM
Definition: shresdef.h:241
#define IDS_FILEOOP_FROM_TO
Definition: shresdef.h:240
#define IDS_FILEOOP_MOVING
Definition: shresdef.h:238
#define IDS_FILEOOP_DELETING
Definition: shresdef.h:239
#define IDS_FILEOOP_COPYING
Definition: shresdef.h:237
#define IDS_FILEOOP_PREFLIGHT
Definition: shresdef.h:242
#define IDA_SHELL_COPY
Definition: shresdef.h:808
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by SHFileOperationW().

◆ add_file_to_entry()

static void add_file_to_entry ( FILE_ENTRY feFile,
LPCWSTR  szFile 
)
static

Definition at line 1128 of file shlfileop.cpp.

1129{
1130 DWORD dwLen = lstrlenW(szFile) + 1;
1131 LPCWSTR ptr;
1132 LPCWSTR ptr2;
1133
1134 feFile->szFullPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
1135 lstrcpyW(feFile->szFullPath, szFile);
1136
1137 ptr = StrRChrW(szFile, NULL, '\\');
1138 ptr2 = StrRChrW(szFile, NULL, '/');
1139 if (!ptr || ptr < ptr2)
1140 ptr = ptr2;
1141 if (ptr)
1142 {
1143 dwLen = ptr - szFile + 1;
1144 feFile->szDirectory = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
1145 lstrcpynW(feFile->szDirectory, szFile, dwLen);
1146
1147 dwLen = lstrlenW(feFile->szFullPath) - dwLen + 1;
1148 feFile->szFilename = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
1149 lstrcpyW(feFile->szFilename, ptr + 1); /* skip over backslash */
1150 }
1151 feFile->bFromWildcard = FALSE;
1152}
LPWSTR WINAPI StrRChrW(LPCWSTR str, LPCWSTR end, WORD ch)
Definition: string.c:552
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
BOOL bFromWildcard
Definition: shlfileop.cpp:58
LPWSTR szFilename
Definition: shlfileop.cpp:56
LPWSTR szDirectory
Definition: shlfileop.cpp:55
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by parse_file_list(), and parse_wildcard_files().

◆ check_flags()

static void check_flags ( FILEOP_FLAGS  fFlags)
static

Definition at line 1877 of file shlfileop.cpp.

1878{
1879 WORD wUnsupportedFlags = FOF_NO_CONNECTED_ELEMENTS |
1882
1883 if (fFlags & wUnsupportedFlags)
1884 FIXME("Unsupported flags: %04x\n", fFlags);
1885}
#define FIXME(fmt,...)
Definition: precomp.h:53
unsigned short WORD
Definition: ntddk_ex.h:93
#define FOF_NOCOPYSECURITYATTRIBS
Definition: shellapi.h:152
#define FOF_NO_CONNECTED_ELEMENTS
Definition: shellapi.h:154
#define FOF_NORECURSEREPARSE
Definition: shellapi.h:156
#define FOF_WANTMAPPINGHANDLE
Definition: shellapi.h:146

Referenced by SHFileOperationW().

◆ CheckForError()

static DWORD CheckForError ( FILE_OPERATION op,
DWORD  error,
LPCWSTR  src 
)
static

Definition at line 673 of file shlfileop.cpp.

674{
675 CStringW strTitle, strMask, strText;
676 LPWSTR lpMsgBuffer;
677
678 if (error == ERROR_SUCCESS || (op->req->fFlags & (FOF_NOERRORUI | FOF_SILENT)))
679 goto exit;
680
681 strTitle.LoadStringW(op->req->wFunc == FO_COPY ? IDS_COPYERRORTITLE : IDS_MOVEERRORTITLE);
682
684 NULL,
685 error,
687 (LPWSTR)&lpMsgBuffer,
688 0,
689 NULL);
690
691 strText.Format(op->req->wFunc == FO_COPY ? IDS_COPYERROR : IDS_MOVEERROR,
693 lpMsgBuffer);
694
695 MessageBoxW(op->req->hwnd, strText, strTitle, MB_ICONERROR);
696 LocalFree(lpMsgBuffer);
697
698exit:
699 return error;
700}
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define error(str)
Definition: mkdosfs.c:1605
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define exit(n)
Definition: config.h:202
#define FOF_NOERRORUI
Definition: shellapi.h:151
#define FOF_SILENT
Definition: shellapi.h:143
#define IDS_MOVEERROR
Definition: shresdef.h:258
#define IDS_COPYERROR
Definition: shresdef.h:259
#define IDS_COPYERRORTITLE
Definition: shresdef.h:252
#define IDS_MOVEERRORTITLE
Definition: shresdef.h:251
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:790

Referenced by SHNotifyCopyFileW(), and SHNotifyMoveFileW().

◆ confirm_delete_list()

static BOOL confirm_delete_list ( HWND  hWnd,
DWORD  fFlags,
BOOL  fTrash,
const FILE_LIST flFrom 
)
static

Definition at line 1563 of file shlfileop.cpp.

1564{
1565 if (flFrom->dwNumFiles > 1)
1566 {
1567 WCHAR tmp[8];
1568
1569 wnsprintfW(tmp, sizeof(tmp)/sizeof(tmp[0]), L"%d", flFrom->dwNumFiles);
1571 }
1572 else
1573 {
1574 const FILE_ENTRY *fileEntry = &flFrom->feFiles[0];
1575
1576 if (IsAttribFile(fileEntry->attributes))
1578 else if (!(fFlags & FOF_FILESONLY && fileEntry->bFromWildcard))
1580 }
1581 return TRUE;
1582}
HWND hWnd
Definition: settings.c:17
int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt,...)
Definition: wsprintf.c:564
#define ASK_TRASH_FOLDER
Definition: shell32_main.h:127
#define ASK_DELETE_MULTIPLE_ITEM
Definition: shell32_main.h:122
#define ASK_DELETE_FILE
Definition: shell32_main.h:120
#define ASK_TRASH_FILE
Definition: shell32_main.h:126
#define ASK_DELETE_FOLDER
Definition: shell32_main.h:121
#define ASK_TRASH_MULTIPLE_ITEM
Definition: shell32_main.h:128
#define FOF_FILESONLY
Definition: shellapi.h:148
#define IsAttribFile(x)
Definition: shlfileop.cpp:30
static BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FILE_OPERATION *op)
Definition: shlfileop.cpp:294
DWORD dwNumFiles
Definition: shlfileop.cpp:67
FILE_ENTRY * feFiles
Definition: shlfileop.cpp:65

Referenced by delete_files().

◆ confirm_msg_move_button()

static void confirm_msg_move_button ( HWND  hDlg,
INT  iId,
INT xPos,
INT  yOffset,
BOOL  bShow 
)
static

Definition at line 97 of file shlfileop.cpp.

98{
99 HWND hButton = GetDlgItem(hDlg, iId);
100 RECT r;
101
102 if (bShow)
103 {
104 POINT pt;
105 int width;
106
107 GetWindowRect(hButton, &r);
108 width = r.right - r.left;
109 pt.x = r.left;
110 pt.y = r.top;
111 ScreenToClient(hDlg, &pt);
112 MoveWindow(hButton, *xPos - width, pt.y - yOffset, width, r.bottom - r.top, FALSE);
113 *xPos -= width + 5;
114 }
115 else
116 ShowWindow(hButton, SW_HIDE);
117}
int yOffset
Definition: appswitch.c:59
#define pt(x, y)
Definition: drawing.c:79
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLsizei width
Definition: gl.h:1546
#define SW_HIDE
Definition: winuser.h:771
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by ConfirmMsgBox_Init().

◆ ConfirmMsgBox_Init()

static INT_PTR ConfirmMsgBox_Init ( HWND  hDlg,
LPARAM  lParam 
)
static

Definition at line 145 of file shlfileop.cpp.

146{
147 struct confirm_msg_info *info = (struct confirm_msg_info *)lParam;
148 INT xPos, yOffset;
149 int width, height;
150 HFONT hOldFont;
151 HDC hdc;
152 RECT r;
153
154 SetWindowTextW(hDlg, info->lpszCaption);
156 SetPropW(hDlg, L"WINE_CONFIRM", info->lpszText);
158
159 /* compute the text height and resize the dialog */
161 hdc = GetDC(hDlg);
162 yOffset = r.bottom;
165 SelectObject(hdc, hOldFont);
166 yOffset -= r.bottom;
167 yOffset = min(yOffset, 35); /* don't make the dialog too small */
168 ReleaseDC(hDlg, hdc);
169
170 GetClientRect(hDlg, &r);
171 xPos = r.right - 7;
172 GetWindowRect(hDlg, &r);
173 width = r.right - r.left;
174 height = r.bottom - r.top - yOffset;
177
178 confirm_msg_move_button(hDlg, IDCANCEL, &xPos, yOffset, info->bYesToAll);
180 confirm_msg_move_button(hDlg, IDC_YESTOALL, &xPos, yOffset, info->bYesToAll);
182
183 return TRUE;
184}
LPARAM lParam
Definition: combotst.c:139
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
static void confirm_msg_move_button(HWND hDlg, INT iId, INT *xPos, INT yOffset, BOOL bShow)
Definition: shlfileop.cpp:97
#define IDC_YESTOALL_MESSAGE
Definition: shresdef.h:431
#define IDC_YESTOALL_ICON
Definition: shresdef.h:430
#define IDC_YESTOALL
Definition: shresdef.h:429
int32_t INT
Definition: typedefs.h:58
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DT_NOPREFIX
Definition: winuser.h:537
#define SM_CYSCREEN
Definition: winuser.h:963
#define STM_SETICON
Definition: winuser.h:2095
#define IDCANCEL
Definition: winuser.h:834
#define WM_GETFONT
Definition: winuser.h:1654
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_WORDBREAK
Definition: winuser.h:544
#define IDNO
Definition: winuser.h:839
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
HDC WINAPI GetDC(_In_opt_ HWND)
#define SM_CXSCREEN
Definition: winuser.h:962
#define IDYES
Definition: winuser.h:838
#define DT_CALCRECT
Definition: winuser.h:526
int WINAPI GetSystemMetrics(_In_ int)
#define DT_PATH_ELLIPSIS
Definition: winuser.h:530

Referenced by ConfirmMsgBoxProc().

◆ ConfirmMsgBox_Paint()

static INT_PTR ConfirmMsgBox_Paint ( HWND  hDlg)
static

Definition at line 122 of file shlfileop.cpp.

123{
124 PAINTSTRUCT ps;
125 HFONT hOldFont;
126 RECT r;
127 HDC hdc;
128
129 BeginPaint(hDlg, &ps);
130 hdc = ps.hdc;
133
135 /* this will remap the rect to dialog coords */
138 DrawTextW(hdc, (LPWSTR)GetPropW(hDlg, L"WINE_CONFIRM"), -1, &r, DT_NOPREFIX | DT_PATH_ELLIPSIS | DT_WORDBREAK);
139 SelectObject(hdc, hOldFont);
140 EndPaint(hDlg, &ps);
141
142 return TRUE;
143}
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_BTNTEXT
Definition: winuser.h:936
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by ConfirmMsgBoxProc().

◆ ConfirmMsgBoxProc()

static INT_PTR CALLBACK ConfirmMsgBoxProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 186 of file shlfileop.cpp.

187{
188 switch (uMsg)
189 {
190 case WM_INITDIALOG:
191 return ConfirmMsgBox_Init(hDlg, lParam);
192 case WM_PAINT:
193 return ConfirmMsgBox_Paint(hDlg);
194 case WM_COMMAND:
195 EndDialog(hDlg, wParam);
196 break;
197 case WM_CLOSE:
198 EndDialog(hDlg, IDCANCEL);
199 break;
200 }
201 return FALSE;
202}
WPARAM wParam
Definition: combotst.c:138
static INT_PTR ConfirmMsgBox_Init(HWND hDlg, LPARAM lParam)
Definition: shlfileop.cpp:145
static INT_PTR ConfirmMsgBox_Paint(HWND hDlg)
Definition: shlfileop.cpp:122
#define WM_PAINT
Definition: winuser.h:1623
#define WM_CLOSE
Definition: winuser.h:1624
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SHELL_ConfirmMsgBox().

◆ copy_dir_to_dir()

static void copy_dir_to_dir ( FILE_OPERATION op,
const FILE_ENTRY feFrom,
LPCWSTR  szDestPath 
)
static

Definition at line 1325 of file shlfileop.cpp.

1326{
1327 WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
1328 FILE_LIST flFromNew, flToNew;
1329
1330 if (feFrom->szFilename && IsDotDir(feFrom->szFilename))
1331 return;
1332
1333 if (PathFileExistsW(szDestPath))
1334 PathCombineW(szTo, szDestPath, feFrom->szFilename);
1335 else
1336 lstrcpyW(szTo, szDestPath);
1337
1338 if (PathFileExistsW(szTo))
1339 {
1340 if (op->req->fFlags & FOF_RENAMEONCOLLISION)
1341 {
1342 CStringW newPath = try_find_new_name(szTo);
1343 if (!newPath.IsEmpty())
1344 {
1345 StringCchCopyW(szTo, _countof(szTo), newPath);
1346 }
1347 }
1348 else if (!(op->req->fFlags & FOF_NOCONFIRMATION))
1349 {
1350 if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FOLDER, feFrom->szFilename, op))
1351 {
1352 /* Vista returns an ERROR_CANCELLED even if user pressed "No" */
1353 if (!op->bManyItems)
1354 op->bCancelled = TRUE;
1355 return;
1356 }
1357 }
1358 }
1359
1360 szTo[lstrlenW(szTo) + 1] = '\0';
1362
1363 PathCombineW(szFrom, feFrom->szFullPath, L"*.*");
1364 szFrom[lstrlenW(szFrom) + 1] = '\0';
1365
1366 ZeroMemory(&flFromNew, sizeof(FILE_LIST));
1367 ZeroMemory(&flToNew, sizeof(FILE_LIST));
1368 parse_file_list(&flFromNew, szFrom);
1369 parse_file_list(&flToNew, szTo);
1370
1371 copy_files(op, FALSE, &flFromNew, &flToNew);
1372
1373 destroy_file_list(&flFromNew);
1374 destroy_file_list(&flToNew);
1375}
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
#define PathCombineW
Definition: pathcch.h:317
#define ASK_OVERWRITE_FOLDER
Definition: shell32_main.h:130
#define FOF_RENAMEONCOLLISION
Definition: shellapi.h:144
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
static HRESULT copy_files(FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flFrom, FILE_LIST *flTo)
Definition: shlfileop.cpp:1436
static HRESULT parse_file_list(FILE_LIST *flList, LPCWSTR szFiles)
Definition: shlfileop.cpp:1210
#define IsDotDir(x)
Definition: shlfileop.cpp:32
static void destroy_file_list(FILE_LIST *flList)
Definition: shlfileop.cpp:1280
static CStringW try_find_new_name(LPCWSTR szDestPath)
Definition: shlfileop.cpp:1297
static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
Definition: shlfileop.cpp:417
#define _countof(array)
Definition: sndvol32.h:70
#define ZeroMemory
Definition: winbase.h:1712

Referenced by copy_files(), and copy_to_dir().

◆ copy_file_to_file()

static BOOL copy_file_to_file ( FILE_OPERATION op,
const WCHAR szFrom,
const WCHAR szTo 
)
static

Definition at line 1377 of file shlfileop.cpp.

1378{
1379 if (PathFileExistsW(szTo))
1380 {
1381 if (op->req->fFlags & FOF_RENAMEONCOLLISION)
1382 {
1383 CStringW newPath = try_find_new_name(szTo);
1384 if (!newPath.IsEmpty())
1385 {
1386 return SHNotifyCopyFileW(op, szFrom, newPath, FALSE) == 0;
1387 }
1388 }
1389 else if (!(op->req->fFlags & FOF_NOCONFIRMATION))
1390 {
1392 return FALSE;
1393 }
1394 }
1395
1396 return SHNotifyCopyFileW(op, szFrom, szTo, FALSE) == 0;
1397}
#define ASK_OVERWRITE_FILE
Definition: shell32_main.h:124
static DWORD SHNotifyCopyFileW(FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
Definition: shlfileop.cpp:782

Referenced by copy_files(), and copy_to_dir().

◆ copy_files()

static HRESULT copy_files ( FILE_OPERATION op,
BOOL  multiDest,
const FILE_LIST flFrom,
FILE_LIST flTo 
)
static

Definition at line 1436 of file shlfileop.cpp.

1437{
1438 DWORD i;
1439 const FILE_ENTRY *entryToCopy;
1440 const FILE_ENTRY *fileDest = &flTo->feFiles[0];
1441
1442 if (flFrom->bAnyDontExist)
1444
1445 if (flTo->dwNumFiles == 0)
1446 {
1447 /* If the destination is empty, SHFileOperation should use the current directory */
1448 WCHAR curdir[MAX_PATH+1];
1449
1451 curdir[lstrlenW(curdir)+1] = 0;
1452
1453 destroy_file_list(flTo);
1454 ZeroMemory(flTo, sizeof(FILE_LIST));
1455 parse_file_list(flTo, curdir);
1456 fileDest = &flTo->feFiles[0];
1457 }
1458
1459 if (multiDest)
1460 {
1461 if (flFrom->bAnyFromWildcard)
1462 return ERROR_CANCELLED;
1463
1464 if (flFrom->dwNumFiles != flTo->dwNumFiles)
1465 {
1466 if (flFrom->dwNumFiles != 1 && !IsAttribDir(fileDest->attributes))
1467 return ERROR_CANCELLED;
1468
1469 /* Free all but the first entry. */
1470 for (i = 1; i < flTo->dwNumFiles; i++)
1471 {
1475 }
1476
1477 flTo->dwNumFiles = 1;
1478 }
1479 else if (IsAttribDir(fileDest->attributes))
1480 {
1481 for (i = 1; i < flTo->dwNumFiles; i++)
1482 if (!IsAttribDir(flTo->feFiles[i].attributes) ||
1483 !IsAttribDir(flFrom->feFiles[i].attributes))
1484 {
1485 return ERROR_CANCELLED;
1486 }
1487 }
1488 }
1489 else if (flFrom->dwNumFiles != 1)
1490 {
1491 if (flTo->dwNumFiles != 1 && !IsAttribDir(fileDest->attributes))
1492 return ERROR_CANCELLED;
1493
1494 if (PathFileExistsW(fileDest->szFullPath) &&
1495 IsAttribFile(fileDest->attributes))
1496 {
1497 return ERROR_CANCELLED;
1498 }
1499
1500 if (flTo->dwNumFiles == 1 && fileDest->bFromRelative &&
1501 !PathFileExistsW(fileDest->szFullPath))
1502 {
1503 return ERROR_CANCELLED;
1504 }
1505 }
1506
1507 for (i = 0; i < flFrom->dwNumFiles; i++)
1508 {
1509 entryToCopy = &flFrom->feFiles[i];
1510
1511 if ((multiDest) &&
1512 flTo->dwNumFiles > 1)
1513 {
1514 fileDest = &flTo->feFiles[i];
1515 }
1516
1517 if (IsAttribDir(entryToCopy->attributes) &&
1518 !lstrcmpiW(entryToCopy->szFullPath, fileDest->szDirectory))
1519 {
1520 return ERROR_SUCCESS;
1521 }
1522
1523 create_dest_dirs(fileDest->szDirectory);
1524
1525 if (!lstrcmpiW(entryToCopy->szFullPath, fileDest->szFullPath))
1526 {
1527 if (IsAttribFile(entryToCopy->attributes))
1529 else
1530 return ERROR_SUCCESS;
1531 }
1532
1533 if ((flFrom->dwNumFiles > 1 && flTo->dwNumFiles == 1) ||
1534 IsAttribDir(fileDest->attributes))
1535 {
1536 copy_to_dir(op, entryToCopy, fileDest);
1537 }
1538 else if (IsAttribDir(entryToCopy->attributes))
1539 {
1540 copy_dir_to_dir(op, entryToCopy, fileDest->szFullPath);
1541 }
1542 else
1543 {
1544 if (!copy_file_to_file(op, entryToCopy->szFullPath, fileDest->szFullPath))
1545 {
1546 op->req->fAnyOperationsAborted = TRUE;
1547 return ERROR_CANCELLED;
1548 }
1549 }
1550
1551 if (op->progress != NULL)
1552 op->bCancelled |= op->progress->HasUserCancelled();
1553 /* Vista return code. XP would return e.g. ERROR_FILE_NOT_FOUND, ERROR_ALREADY_EXISTS */
1554 if (op->bCancelled)
1555 return ERROR_CANCELLED;
1556 }
1557
1558 /* Vista return code. On XP if the used pressed "No" for the last item,
1559 * ERROR_ARENA_TRASHED would be returned */
1560 return ERROR_SUCCESS;
1561}
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
#define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND
Definition: shlfileop.cpp:50
static void copy_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo)
Definition: shlfileop.cpp:1400
static void create_dest_dirs(LPCWSTR szDestDir)
Definition: shlfileop.cpp:1416
static BOOL copy_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
Definition: shlfileop.cpp:1377
static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWSTR szDestPath)
Definition: shlfileop.cpp:1325
BOOL bFromRelative
Definition: shlfileop.cpp:59
BOOL bAnyFromWildcard
Definition: shlfileop.cpp:68
BOOL bAnyDontExist
Definition: shlfileop.cpp:70
#define ERROR_NO_MORE_SEARCH_HANDLES
Definition: winerror.h:187
#define ERROR_CANCELLED
Definition: winerror.h:726

Referenced by copy_dir_to_dir(), and SHFileOperationW().

◆ copy_to_dir()

static void copy_to_dir ( FILE_OPERATION op,
const FILE_ENTRY feFrom,
const FILE_ENTRY feTo 
)
static

Definition at line 1400 of file shlfileop.cpp.

1401{
1402 if (!PathFileExistsW(feTo->szFullPath))
1404
1405 if (IsAttribFile(feFrom->attributes))
1406 {
1407 WCHAR szDestPath[MAX_PATH];
1408
1409 PathCombineW(szDestPath, feTo->szFullPath, feFrom->szFilename);
1410 copy_file_to_file(op, feFrom->szFullPath, szDestPath);
1411 }
1412 else if (!(op->req->fFlags & FOF_FILESONLY && feFrom->bFromWildcard))
1413 copy_dir_to_dir(op, feFrom, feTo->szFullPath);
1414}

Referenced by copy_files().

◆ create_dest_dirs()

static void create_dest_dirs ( LPCWSTR  szDestDir)
static

Definition at line 1416 of file shlfileop.cpp.

1417{
1419 LPCWSTR ptr = StrChrW(szDestDir, '\\');
1420
1421 /* make sure all directories up to last one are created */
1422 while (ptr && (ptr = StrChrW(ptr + 1, '\\')))
1423 {
1424 lstrcpynW(dir, szDestDir, ptr - szDestDir + 1);
1425
1426 if (!PathFileExistsW(dir))
1428 }
1429
1430 /* create last directory */
1431 if (!PathFileExistsW(szDestDir))
1432 SHNotifyCreateDirectoryW(szDestDir, NULL);
1433}
unsigned int dir
Definition: maze.c:112
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464

Referenced by copy_files(), and move_files().

◆ delete_files()

static HRESULT delete_files ( FILE_OPERATION op,
const FILE_LIST flFrom 
)
static

Definition at line 1585 of file shlfileop.cpp.

1586{
1587 const FILE_ENTRY *fileEntry;
1588 DWORD i;
1589 BOOL bPathExists;
1590 BOOL bTrash;
1591
1592 if (!flFrom->dwNumFiles)
1593 return ERROR_SUCCESS;
1594
1595 /* Windows also checks only the first item */
1596 bTrash = (op->req->fFlags & FOF_ALLOWUNDO)
1597 && TRASH_CanTrashFile(flFrom->feFiles[0].szFullPath);
1598
1599 if (!(op->req->fFlags & FOF_NOCONFIRMATION) || (!bTrash && op->req->fFlags & FOF_WANTNUKEWARNING))
1600 if (!confirm_delete_list(op->req->hwnd, op->req->fFlags, bTrash, flFrom))
1601 {
1602 op->req->fAnyOperationsAborted = TRUE;
1603 return 0;
1604 }
1605
1606 /* Check files. Do not delete one if one file does not exists */
1607 for (i = 0; i < flFrom->dwNumFiles; i++)
1608 {
1609 fileEntry = &flFrom->feFiles[i];
1610
1611 if (fileEntry->attributes == (ULONG)-1)
1612 {
1613 // This is a windows 2003 server specific value which has been removed.
1614 // Later versions of windows return ERROR_FILE_NOT_FOUND.
1616 }
1617 }
1618
1619 for (i = 0; i < flFrom->dwNumFiles; i++)
1620 {
1621 bPathExists = TRUE;
1622 fileEntry = &flFrom->feFiles[i];
1623
1624 if (!IsAttribFile(fileEntry->attributes) &&
1625 (op->req->fFlags & FOF_FILESONLY && fileEntry->bFromWildcard))
1626 continue;
1627
1628 if (bTrash)
1629 {
1630 BOOL bDelete;
1631 if (TRASH_TrashFile(fileEntry->szFullPath))
1632 {
1634 continue;
1635 }
1636
1637 /* Note: Windows silently deletes the file in such a situation, we show a dialog */
1638 if (!(op->req->fFlags & FOF_NOCONFIRMATION) || (op->req->fFlags & FOF_WANTNUKEWARNING))
1639 bDelete = SHELL_ConfirmDialogW(op->req->hwnd, ASK_CANT_TRASH_ITEM, fileEntry->szFullPath, NULL);
1640 else
1641 bDelete = TRUE;
1642
1643 if (!bDelete)
1644 {
1645 op->req->fAnyOperationsAborted = TRUE;
1646 break;
1647 }
1648 }
1649
1650 /* delete the file or directory */
1651 if (IsAttribFile(fileEntry->attributes))
1652 {
1653 bPathExists = (ERROR_SUCCESS == SHNotifyDeleteFileW(op, fileEntry->szFullPath));
1654 }
1655 else
1656 bPathExists = SHELL_DeleteDirectoryW(op, fileEntry->szFullPath, FALSE);
1657
1658 if (!bPathExists)
1659 {
1661
1663 {
1664 // This is a windows 2003 server specific value which ahs been removed.
1665 // Later versions of windows return ERROR_FILE_NOT_FOUND.
1667 }
1668 else
1669 {
1670 return err;
1671 }
1672 }
1673
1674 if (op->progress != NULL)
1675 op->bCancelled |= op->progress->HasUserCancelled();
1676 /* Should fire on progress dialog only */
1677 if (op->bCancelled)
1678 return ERROR_CANCELLED;
1679 }
1680
1681 return ERROR_SUCCESS;
1682}
BOOL TRASH_TrashFile(LPCWSTR wszPath)
BOOL TRASH_CanTrashFile(LPCWSTR wszPath)
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ASK_CANT_TRASH_ITEM
Definition: shell32_main.h:129
#define FOF_WANTNUKEWARNING
Definition: shellapi.h:155
#define FOF_ALLOWUNDO
Definition: shellapi.h:147
BOOL SHELL_DeleteDirectoryW(FILE_OPERATION *op, LPCWSTR pszDir, BOOL bShowUI)
Definition: shlfileop.cpp:370
static BOOL confirm_delete_list(HWND hWnd, DWORD fFlags, BOOL fTrash, const FILE_LIST *flFrom)
Definition: shlfileop.cpp:1563
static DWORD SHNotifyDeleteFileW(FILE_OPERATION *op, LPCWSTR path)
Definition: shlfileop.cpp:606
#define SHCNE_DELETE
Definition: shlobj.h:1892
#define SHCNF_PATHW
Definition: shlobj.h:1925
uint32_t ULONG
Definition: typedefs.h:59

Referenced by SHFileOperationW().

◆ destroy_file_list()

static void destroy_file_list ( FILE_LIST flList)
static

Definition at line 1280 of file shlfileop.cpp.

1281{
1282 DWORD i;
1283
1284 if (!flList || !flList->feFiles)
1285 return;
1286
1287 for (i = 0; i < flList->dwNumFiles; i++)
1288 {
1290 HeapFree(GetProcessHeap(), 0, flList->feFiles[i].szFilename);
1291 HeapFree(GetProcessHeap(), 0, flList->feFiles[i].szFullPath);
1292 }
1293
1294 HeapFree(GetProcessHeap(), 0, flList->feFiles);
1295}

Referenced by copy_dir_to_dir(), copy_files(), move_dir_to_dir(), and SHFileOperationW().

◆ grow_list()

static void __inline grow_list ( FILE_LIST list)
static

Definition at line 1118 of file shlfileop.cpp.

1119{
1121 list->num_alloc * 2 * sizeof(*newx) );
1122 list->feFiles = newx;
1123 list->num_alloc *= 2;
1124}
Definition: list.h:37
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

Referenced by parse_file_list(), and parse_wildcard_files().

◆ IsNetDrive()

EXTERN_C int WINAPI IsNetDrive ( int  drive)

Definition at line 2213 of file shlfileop.cpp.

2214{
2215 char root[4];
2216 strcpy(root, "A:\\");
2217 root[0] += (char)drive;
2218 return (GetDriveTypeA(root) == DRIVE_REMOTE);
2219}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
UINT WINAPI GetDriveTypeA(IN LPCSTR lpRootPathName)
Definition: disk.c:468
unsigned char
Definition: typeof.h:29
#define DRIVE_REMOTE
Definition: winbase.h:253

Referenced by PathIsNetworkPathA(), and PathIsNetworkPathW().

◆ move_dir_to_dir()

static void move_dir_to_dir ( FILE_OPERATION op,
const FILE_ENTRY feFrom,
LPCWSTR  szDestPath 
)
static

Definition at line 1684 of file shlfileop.cpp.

1685{
1686 WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
1687 FILE_LIST flFromNew, flToNew;
1688
1689 if (feFrom->szFilename && IsDotDir(feFrom->szFilename))
1690 return;
1691
1692 SHNotifyCreateDirectoryW(szDestPath, NULL);
1693
1694 PathCombineW(szFrom, feFrom->szFullPath, L"*.*");
1695 szFrom[lstrlenW(szFrom) + 1] = '\0';
1696
1697 lstrcpyW(szTo, szDestPath);
1698 szTo[lstrlenW(szDestPath) + 1] = '\0';
1699
1700 ZeroMemory(&flFromNew, sizeof(FILE_LIST));
1701 ZeroMemory(&flToNew, sizeof(FILE_LIST));
1702 parse_file_list(&flFromNew, szFrom);
1703 parse_file_list(&flToNew, szTo);
1704
1705 move_files(op, FALSE, &flFromNew, &flToNew);
1706
1707 destroy_file_list(&flFromNew);
1708 destroy_file_list(&flToNew);
1709
1710 if (PathIsDirectoryEmptyW(feFrom->szFullPath))
1712}
BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath)
Definition: path.c:3931
EXTERN_C BOOL WINAPI Win32RemoveDirectoryW(LPCWSTR path)
Definition: shlfileop.cpp:471
static DWORD move_files(FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flFrom, const FILE_LIST *flTo)
Definition: shlfileop.cpp:1755

Referenced by move_files(), and move_to_dir().

◆ move_file_to_file()

static BOOL move_file_to_file ( FILE_OPERATION op,
const WCHAR szFrom,
const WCHAR szTo 
)
static

Definition at line 1714 of file shlfileop.cpp.

1715{
1716 if (PathFileExistsW(szTo))
1717 {
1718 if (op->req->fFlags & FOF_RENAMEONCOLLISION)
1719 {
1720 CStringW newPath = try_find_new_name(szTo);
1721 if (!newPath.IsEmpty())
1722 {
1723 return SHNotifyMoveFileW(op, szFrom, newPath, FALSE) == 0;
1724 }
1725 }
1726 else if (!(op->req->fFlags & FOF_NOCONFIRMATION))
1727 {
1729 return FALSE;
1730 }
1731 }
1732
1733 return SHNotifyMoveFileW(op, szFrom, szTo, FALSE) == 0;
1734}
static DWORD SHNotifyMoveFileW(FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest, BOOL isdir)
Definition: shlfileop.cpp:715

Referenced by move_files(), and move_to_dir().

◆ move_files()

static DWORD move_files ( FILE_OPERATION op,
BOOL  multiDest,
const FILE_LIST flFrom,
const FILE_LIST flTo 
)
static

Definition at line 1755 of file shlfileop.cpp.

1756{
1757 DWORD i;
1758 INT mismatched = 0;
1759
1760 const FILE_ENTRY *entryToMove;
1761 const FILE_ENTRY *fileDest;
1762
1763 if (!flFrom->dwNumFiles)
1764 return ERROR_SUCCESS;
1765
1766 if (!flTo->dwNumFiles)
1767 return ERROR_FILE_NOT_FOUND;
1768
1769 if (flFrom->bAnyDontExist)
1771
1772 if (!(multiDest) &&
1773 flTo->dwNumFiles > 1 && flFrom->dwNumFiles > 1)
1774 {
1775 return ERROR_CANCELLED;
1776 }
1777
1778 if (!(multiDest) &&
1779 !flFrom->bAnyDirectories &&
1780 flFrom->dwNumFiles > flTo->dwNumFiles &&
1781 !(flTo->bAnyDirectories && flTo->dwNumFiles == 1))
1782 {
1783 return ERROR_CANCELLED;
1784 }
1785
1786 if (!PathFileExistsW(flTo->feFiles[0].szDirectory))
1787 return ERROR_CANCELLED;
1788
1789 if (multiDest)
1790 mismatched = flFrom->dwNumFiles - flTo->dwNumFiles;
1791
1792 fileDest = &flTo->feFiles[0];
1793 for (i = 0; i < flFrom->dwNumFiles; i++)
1794 {
1795 entryToMove = &flFrom->feFiles[i];
1796
1797 if (!PathFileExistsW(fileDest->szDirectory))
1798 return ERROR_CANCELLED;
1799
1800 if (multiDest)
1801 {
1802 if (i >= flTo->dwNumFiles)
1803 break;
1804 fileDest = &flTo->feFiles[i];
1805 if (mismatched && !fileDest->bExists)
1806 {
1808 flTo->feFiles[i].bExists = TRUE;
1810 }
1811 }
1812
1813 if ((flFrom->dwNumFiles > 1 && flTo->dwNumFiles == 1) ||
1814 IsAttribDir(fileDest->attributes))
1815 {
1816 move_to_dir(op, entryToMove, fileDest);
1817 }
1818 else if (IsAttribDir(entryToMove->attributes))
1819 {
1820 move_dir_to_dir(op, entryToMove, fileDest->szFullPath);
1821 }
1822 else
1823 {
1824 if (!move_file_to_file(op, entryToMove->szFullPath, fileDest->szFullPath))
1825 {
1826 op->req->fAnyOperationsAborted = TRUE;
1827 return ERROR_CANCELLED;
1828 }
1829 }
1830
1831 if (op->progress != NULL)
1832 op->bCancelled |= op->progress->HasUserCancelled();
1833 /* Should fire on progress dialog only */
1834 if (op->bCancelled)
1835 return ERROR_CANCELLED;
1836
1837 }
1838
1839 if (mismatched > 0)
1840 {
1841 if (flFrom->bAnyDirectories)
1842 return DE_DESTSAMETREE;
1843 else
1844 return DE_SAMEFILE;
1845 }
1846
1847 return ERROR_SUCCESS;
1848}
#define DE_DESTSAMETREE
Definition: shlfileop.c:48
#define DE_SAMEFILE
Definition: shlfileop.c:42
static void move_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, const FILE_ENTRY *feTo)
Definition: shlfileop.cpp:1737
static BOOL move_file_to_file(FILE_OPERATION *op, const WCHAR *szFrom, const WCHAR *szTo)
Definition: shlfileop.cpp:1714
static void move_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWSTR szDestPath)
Definition: shlfileop.cpp:1684
BOOL bExists
Definition: shlfileop.cpp:60
BOOL bAnyDirectories
Definition: shlfileop.cpp:69

Referenced by move_dir_to_dir(), and SHFileOperationW().

◆ move_to_dir()

static void move_to_dir ( FILE_OPERATION op,
const FILE_ENTRY feFrom,
const FILE_ENTRY feTo 
)
static

Definition at line 1737 of file shlfileop.cpp.

1738{
1739 if (feFrom->attributes == INVALID_FILE_ATTRIBUTES)
1740 return;
1741
1742 if (!PathFileExistsW(feTo->szFullPath))
1744
1745 WCHAR szDestPath[MAX_PATH];
1746 PathCombineW(szDestPath, feTo->szFullPath, feFrom->szFilename);
1747
1748 if (IsAttribFile(feFrom->attributes))
1749 move_file_to_file(op, feFrom->szFullPath, szDestPath);
1750 else if (!(op->req->fFlags & FOF_FILESONLY && feFrom->bFromWildcard))
1751 move_dir_to_dir(op, feFrom, szDestPath);
1752}
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by move_files().

◆ parse_file_list()

static HRESULT parse_file_list ( FILE_LIST flList,
LPCWSTR  szFiles 
)
static

Definition at line 1210 of file shlfileop.cpp.

1211{
1212 LPCWSTR ptr = szFiles;
1213 WCHAR szCurFile[MAX_PATH];
1214 DWORD i = 0;
1215
1216 if (!szFiles)
1218
1219 flList->bAnyFromWildcard = FALSE;
1220 flList->bAnyDirectories = FALSE;
1221 flList->bAnyDontExist = FALSE;
1222 flList->num_alloc = 32;
1223 flList->dwNumFiles = 0;
1224
1225 /* empty list */
1226 if (!szFiles[0])
1227 return ERROR_ACCESS_DENIED;
1228
1230 flList->num_alloc * sizeof(FILE_ENTRY));
1231
1232 while (*ptr)
1233 {
1234 if (i >= flList->num_alloc) grow_list( flList );
1235
1236 /* change relative to absolute path */
1237 if (PathIsRelativeW(ptr))
1238 {
1239 GetCurrentDirectoryW(MAX_PATH, szCurFile);
1240 PathCombineW(szCurFile, szCurFile, ptr);
1241 flList->feFiles[i].bFromRelative = TRUE;
1242 }
1243 else
1244 {
1245 lstrcpyW(szCurFile, ptr);
1246 flList->feFiles[i].bFromRelative = FALSE;
1247 }
1248
1249 /* parse wildcard files if they are in the filename */
1250 if (StrPBrkW(szCurFile, L"*?"))
1251 {
1252 parse_wildcard_files(flList, szCurFile, &i);
1253 flList->bAnyFromWildcard = TRUE;
1254 i--;
1255 }
1256 else
1257 {
1258 FILE_ENTRY *file = &flList->feFiles[i];
1259 add_file_to_entry(file, szCurFile);
1260 file->attributes = GetFileAttributesW( file->szFullPath );
1261 file->bExists = (file->attributes != INVALID_FILE_ATTRIBUTES);
1262
1263 if (!file->bExists)
1264 flList->bAnyDontExist = TRUE;
1265
1266 if (IsAttribDir(file->attributes))
1267 flList->bAnyDirectories = TRUE;
1268 }
1269
1270 /* advance to the next string */
1271 ptr += lstrlenW(ptr) + 1;
1272 i++;
1273 }
1274 flList->dwNumFiles = i;
1275
1276 return S_OK;
1277}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
LPWSTR WINAPI StrPBrkW(LPCWSTR lpszStr, LPCWSTR lpszMatch)
Definition: string.c:1284
#define S_OK
Definition: intsafe.h:52
static void parse_wildcard_files(FILE_LIST *flList, LPCWSTR szFile, LPDWORD pdwListIndex)
Definition: shlfileop.cpp:1176
static void __inline grow_list(FILE_LIST *list)
Definition: shlfileop.cpp:1118
static void add_file_to_entry(FILE_ENTRY *feFile, LPCWSTR szFile)
Definition: shlfileop.cpp:1128
DWORD num_alloc
Definition: shlfileop.cpp:66
Definition: fci.c:127

Referenced by copy_dir_to_dir(), copy_files(), move_dir_to_dir(), and SHFileOperationW().

◆ parse_wildcard_files()

static void parse_wildcard_files ( FILE_LIST flList,
LPCWSTR  szFile,
LPDWORD  pdwListIndex 
)
static

Definition at line 1176 of file shlfileop.cpp.

1177{
1178 WIN32_FIND_DATAW wfd;
1179 HANDLE hFile = FindFirstFileW(szFile, &wfd);
1181 LPWSTR szFullPath;
1182 BOOL res;
1183
1184 if (hFile == INVALID_HANDLE_VALUE) return;
1185
1186 for (res = TRUE; res; res = FindNextFileW(hFile, &wfd))
1187 {
1188 if (IsDotDir(wfd.cFileName))
1189 continue;
1190
1191 if (*pdwListIndex >= flList->num_alloc)
1192 grow_list( flList );
1193
1194 szFullPath = wildcard_to_file(szFile, wfd.cFileName);
1195 file = &flList->feFiles[(*pdwListIndex)++];
1196 add_file_to_entry(file, szFullPath);
1197 file->bFromWildcard = TRUE;
1198 file->attributes = wfd.dwFileAttributes;
1199
1200 if (IsAttribDir(file->attributes))
1201 flList->bAnyDirectories = TRUE;
1202
1203 HeapFree(GetProcessHeap(), 0, szFullPath);
1204 }
1205
1207}
GLuint res
Definition: glext.h:9613
_In_ HANDLE hFile
Definition: mswsock.h:90
static LPWSTR wildcard_to_file(LPCWSTR szWildCard, LPCWSTR szFileName)
Definition: shlfileop.cpp:1154

Referenced by parse_file_list().

◆ RealDriveType()

EXTERN_C INT WINAPI RealDriveType ( INT  drive,
BOOL  bQueryNet 
)

Definition at line 2225 of file shlfileop.cpp.

2226{
2227 char root[] = "A:\\";
2228 root[0] += (char)drive;
2229 return GetDriveTypeA(root);
2230}

Referenced by SHIsRemovableDrive().

◆ rename_files()

static HRESULT rename_files ( FILE_OPERATION op,
const FILE_LIST flFrom,
const FILE_LIST flTo 
)
static

Definition at line 1851 of file shlfileop.cpp.

1852{
1853 const FILE_ENTRY *feFrom;
1854 const FILE_ENTRY *feTo;
1855
1856 if (flFrom->dwNumFiles != 1)
1857 return ERROR_GEN_FAILURE;
1858
1859 if (flTo->dwNumFiles != 1)
1860 return ERROR_CANCELLED;
1861
1862 feFrom = &flFrom->feFiles[0];
1863 feTo= &flTo->feFiles[0];
1864
1865 /* fail if destination doesn't exist */
1866 if (!feFrom->bExists)
1868
1869 /* fail if destination already exists */
1870 if (feTo->bExists)
1871 return ERROR_ALREADY_EXISTS;
1872
1873 return SHNotifyMoveFileW(op, feFrom->szFullPath, feTo->szFullPath, IsAttribDir(feFrom->attributes));
1874}
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_GEN_FAILURE
Definition: winerror.h:134

Referenced by SHFileOperationW().

◆ SHCopyProgressRoutine()

DWORD CALLBACK SHCopyProgressRoutine ( LARGE_INTEGER  TotalFileSize,
LARGE_INTEGER  TotalBytesTransferred,
LARGE_INTEGER  StreamSize,
LARGE_INTEGER  StreamBytesTransferred,
DWORD  dwStreamNumber,
DWORD  dwCallbackReason,
HANDLE  hSourceFile,
HANDLE  hDestinationFile,
LPVOID  lpData 
)

Definition at line 559 of file shlfileop.cpp.

569 {
570 FILE_OPERATION *op = (FILE_OPERATION *) lpData;
571
572 if (op->progress) {
573 /*
574 * This is called at the start of each file. To keop less state,
575 * I'm adding the file to the completed size here, and the re-subtracting
576 * it when drawing the progress bar.
577 */
578 if (dwCallbackReason & CALLBACK_STREAM_SWITCH)
579 op->completedSize.QuadPart += TotalFileSize.QuadPart;
580
581 op->progress->SetProgress64(op->completedSize.QuadPart -
582 TotalFileSize.QuadPart +
583 TotalBytesTransferred.QuadPart
584 , op->totalSize.QuadPart);
585
586
587 op->bCancelled = op->progress->HasUserCancelled();
588 }
589
590 return 0;
591}
#define CALLBACK_STREAM_SWITCH
Definition: winbase.h:151

Referenced by SHNotifyCopyFileW(), SHNotifyDeleteFileW(), and SHNotifyMoveFileW().

◆ SHCreateDirectory()

int WINAPI SHCreateDirectory ( HWND  hWnd,
LPCWSTR  path 
)

Definition at line 848 of file shlfileop.cpp.

849{
851}
int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
Definition: shlfileop.cpp:906

Referenced by CreateDirectoryTree(), CNewMenu::CreateNewFolder(), and CDefaultContextMenu::DoCreateNewFolder().

◆ SHCreateDirectoryExA()

int WINAPI SHCreateDirectoryExA ( HWND  hWnd,
LPCSTR  path,
LPSECURITY_ATTRIBUTES  sec 
)

Definition at line 885 of file shlfileop.cpp.

886{
887 LPWSTR wPath;
888 DWORD retCode;
889
890 TRACE("(%s, %p)\n", debugstr_a(path), sec);
891
892 retCode = SHELL32_AnsiToUnicodeBuf(path, &wPath, 0);
893 if (!retCode)
894 {
895 retCode = SHCreateDirectoryExW(hWnd, wPath, sec);
897 }
898 return retCode;
899}
#define debugstr_a
Definition: kernel32.h:31
static void SHELL32_FreeUnicodeBuf(LPWSTR wPath)
Definition: shlfileop.cpp:353
static DWORD SHELL32_AnsiToUnicodeBuf(LPCSTR aPath, LPWSTR *wPath, DWORD minChars)
Definition: shlfileop.cpp:337
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by test_sh_create_dir().

◆ SHCreateDirectoryExW()

int WINAPI SHCreateDirectoryExW ( HWND  hWnd,
LPCWSTR  path,
LPSECURITY_ATTRIBUTES  sec 
)

Definition at line 906 of file shlfileop.cpp.

907{
909 TRACE("(%p, %s, %p)\n", hWnd, debugstr_w(path), sec);
910
912 {
914 }
915 else
916 {
918 /* Refuse to work on certain error codes before trying to create directories recursively */
919 if (ret != ERROR_SUCCESS &&
923 {
924 WCHAR *pEnd, *pSlash, szTemp[MAX_PATH + 1]; /* extra for PathAddBackslash() */
925
926 lstrcpynW(szTemp, path, MAX_PATH);
927 pEnd = PathAddBackslashW(szTemp);
928 pSlash = szTemp + 3;
929
930 while (*pSlash)
931 {
932 while (*pSlash && *pSlash != '\\') pSlash++;
933 if (*pSlash)
934 {
935 *pSlash = 0; /* terminate path at separator */
936
937 ret = SHNotifyCreateDirectoryW(szTemp, pSlash + 1 == pEnd ? sec : NULL);
938 }
939 *pSlash++ = '\\'; /* put the separator back */
940 }
941 }
942
943 if (ret && hWnd && (ERROR_CANCELLED != ret && ERROR_ALREADY_EXISTS != ret))
944 {
948 }
949 }
950
951 return ret;
952}
#define SetLastError(x)
Definition: compat.h:752
#define ShellMessageBoxW
Definition: precomp.h:62
#define debugstr_w
Definition: kernel32.h:32
#define PathAddBackslashW
Definition: pathcch.h:301
#define IDS_CREATEFOLDER_DENIED
Definition: shresdef.h:120
#define IDS_CREATEFOLDER_CAPTION
Definition: shresdef.h:121
int ret
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263
#define MB_ICONEXCLAMATION
Definition: winuser.h:788
#define MB_OK
Definition: winuser.h:793
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by create_target_directory(), SHCreateDirectory(), SHCreateDirectoryExA(), SHGetFolderPathAndSubDirW(), SHPathPrepareForWriteW(), test_unicode(), and wWinMain().

◆ SheChangeDirA()

EXTERN_C DWORD WINAPI SheChangeDirA ( LPSTR  path)

Definition at line 2188 of file shlfileop.cpp.

2189{
2191 return 0;
2192 else
2193 return GetLastError();
2194}
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2206

◆ SheChangeDirW()

EXTERN_C DWORD WINAPI SheChangeDirW ( LPWSTR  path)

Definition at line 2202 of file shlfileop.cpp.

2203{
2205 return 0;
2206 else
2207 return GetLastError();
2208}
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249

◆ SheGetDirA()

EXTERN_C DWORD WINAPI SheGetDirA ( DWORD  drive,
LPSTR  buffer 
)

Definition at line 2115 of file shlfileop.cpp.

2116{
2117 WCHAR org_path[MAX_PATH];
2118 DWORD ret;
2119 char drv_path[3];
2120
2121 /* change current directory to the specified drive */
2122 if (drive) {
2123 strcpy(drv_path, "A:");
2124 drv_path[0] += (char)drive-1;
2125
2126 GetCurrentDirectoryW(MAX_PATH, org_path);
2127
2128 SetCurrentDirectoryA(drv_path);
2129 }
2130
2131 /* query current directory path of the specified drive */
2133
2134 /* back to the original drive */
2135 if (drive)
2136 SetCurrentDirectoryW(org_path);
2137
2138 if (!ret)
2139 return GetLastError();
2140
2141 return 0;
2142}
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
GLuint buffer
Definition: glext.h:5915

◆ SheGetDirW()

EXTERN_C DWORD WINAPI SheGetDirW ( DWORD  drive,
LPWSTR  buffer 
)

Definition at line 2152 of file shlfileop.cpp.

2153{
2154 WCHAR org_path[MAX_PATH];
2155 DWORD ret;
2156 char drv_path[3];
2157
2158 /* change current directory to the specified drive */
2159 if (drive)
2160 {
2161 strcpy(drv_path, "A:");
2162 drv_path[0] += (char)drive-1;
2163
2164 GetCurrentDirectoryW(MAX_PATH, org_path);
2165
2166 SetCurrentDirectoryA(drv_path);
2167 }
2168
2169 /* query current directory path of the specified drive */
2171
2172 /* back to the original drive */
2173 if (drive)
2174 SetCurrentDirectoryW(org_path);
2175
2176 if (!ret)
2177 return GetLastError();
2178
2179 return 0;
2180}

◆ SHELL32_AnsiToUnicodeBuf()

static DWORD SHELL32_AnsiToUnicodeBuf ( LPCSTR  aPath,
LPWSTR wPath,
DWORD  minChars 
)
static

Definition at line 337 of file shlfileop.cpp.

338{
339 DWORD len = MultiByteToWideChar(CP_ACP, 0, aPath, -1, NULL, 0);
340
341 if (len < minChars)
342 len = minChars;
343
344 *wPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
345 if (*wPath)
346 {
347 MultiByteToWideChar(CP_ACP, 0, aPath, -1, *wPath, len);
348 return NO_ERROR;
349 }
350 return E_OUTOFMEMORY;
351}
#define NO_ERROR
Definition: dderror.h:5
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLenum GLsizei len
Definition: glext.h:6722

Referenced by SHCreateDirectoryExA().

◆ SHELL32_FreeUnicodeBuf()

static void SHELL32_FreeUnicodeBuf ( LPWSTR  wPath)
static

Definition at line 353 of file shlfileop.cpp.

354{
355 HeapFree(GetProcessHeap(), 0, wPath);
356}

Referenced by SHCreateDirectoryExA().

◆ SHELL_ConfirmDialogW()

static BOOL SHELL_ConfirmDialogW ( HWND  hWnd,
int  nKindOfDialog,
LPCWSTR  szDir,
FILE_OPERATION op 
)
static

Definition at line 294 of file shlfileop.cpp.

295{
296 WCHAR szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
298 DWORD_PTR args[1];
299 HICON hIcon;
300 int ret;
301
302 assert(nKindOfDialog >= 0 && nKindOfDialog < 32);
303 if (op && (op->dwYesToAllMask & (1 << nKindOfDialog)))
304 return TRUE;
305
306 if (!SHELL_ConfirmIDs(nKindOfDialog, &ids)) return FALSE;
307
308 LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, sizeof(szCaption)/sizeof(WCHAR));
309 LoadStringW(shell32_hInstance, ids.text_resource_id, szText, sizeof(szText)/sizeof(WCHAR));
310
311 args[0] = (DWORD_PTR)szDir;
313 szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)args);
314 hIcon = LoadIconW(ids.hIconInstance, (LPWSTR)MAKEINTRESOURCE(ids.icon_resource_id));
315
316 ret = SHELL_ConfirmMsgBox(hWnd, szBuffer, szCaption, hIcon, op && op->bManyItems);
317 if (op)
318 {
319 if (ret == IDC_YESTOALL)
320 {
321 op->dwYesToAllMask |= (1 << nKindOfDialog);
322 ret = IDYES;
323 }
324 if (ret == IDCANCEL)
325 op->bCancelled = TRUE;
326 if (ret != IDYES)
327 op->req->fAnyOperationsAborted = TRUE;
328 }
329 return ret == IDYES;
330}
#define assert(x)
Definition: debug.h:53
GLuint * ids
Definition: glext.h:5907
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
static BOOL SHELL_ConfirmIDs(int nKindOfDialog, SHELL_ConfirmIDstruc *ids)
Definition: shlfileop.cpp:223
int SHELL_ConfirmMsgBox(HWND hWnd, LPWSTR lpszText, LPWSTR lpszCaption, HICON hIcon, BOOL bYesToAll)
Definition: shlfileop.cpp:204
#define MAKEINTRESOURCE
Definition: winuser.h:591
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2119

Referenced by confirm_delete_list(), copy_dir_to_dir(), copy_file_to_file(), delete_files(), move_file_to_file(), SHELL_ConfirmYesNoW(), and SHELL_DeleteDirectoryW().

◆ SHELL_ConfirmIDs()

static BOOL SHELL_ConfirmIDs ( int  nKindOfDialog,
SHELL_ConfirmIDstruc ids 
)
static

Definition at line 223 of file shlfileop.cpp.

224{
225 ids->hIconInstance = shell32_hInstance;
226 switch (nKindOfDialog)
227 {
228 case ASK_DELETE_FILE:
229 ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
230 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
231 ids->text_resource_id = IDS_DELETEITEM_TEXT;
232 return TRUE;
233
235 ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
236 ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
237 ids->text_resource_id = IDS_DELETEITEM_TEXT;
238 return TRUE;
239
241 ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
242 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
243 ids->text_resource_id = IDS_DELETEMULTIPLE_TEXT;
244 return TRUE;
245
246 case ASK_TRASH_FILE:
247 ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
248 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
249 ids->text_resource_id = IDS_TRASHITEM_TEXT;
250 return TRUE;
251
252 case ASK_TRASH_FOLDER:
253 ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
254 ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
255 ids->text_resource_id = IDS_TRASHFOLDER_TEXT;
256 return TRUE;
257
259 ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
260 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
261 ids->text_resource_id = IDS_TRASHMULTIPLE_TEXT;
262 return TRUE;
263
265 ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
266 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
267 ids->text_resource_id = IDS_CANTTRASH_TEXT;
268 return TRUE;
269
271 ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
272 ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
273 ids->text_resource_id = IDS_DELETESELECTED_TEXT;
274 return TRUE;
275
277 ids->icon_resource_id = IDI_SHELL_FOLDER_MOVE2;
278 ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION;
279 ids->text_resource_id = IDS_OVERWRITEFILE_TEXT;
280 return TRUE;
281
283 ids->icon_resource_id = IDI_SHELL_FOLDER_MOVE2;
284 ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION;
285 ids->text_resource_id = IDS_OVERWRITEFOLDER_TEXT;
286 return TRUE;
287
288 default:
289 FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog);
290 }
291 return FALSE;
292}
#define IDS_OVERWRITEFILE_TEXT
Definition: resource.h:67
#define ASK_DELETE_SELECTED
Definition: shell32_main.h:125
#define IDS_DELETESELECTED_TEXT
Definition: shresdef.h:128
#define IDI_SHELL_FOLDER_MOVE2
Definition: shresdef.h:704
#define IDI_SHELL_CONFIRM_DELETE
Definition: shresdef.h:631
#define IDS_OVERWRITEFOLDER_TEXT
Definition: shresdef.h:133
#define IDS_OVERWRITEFILE_CAPTION
Definition: shresdef.h:126
#define IDS_CANTTRASH_TEXT
Definition: shresdef.h:132
#define IDS_TRASHITEM_TEXT
Definition: shresdef.h:130
#define IDS_DELETEITEM_CAPTION
Definition: shresdef.h:122
#define IDS_TRASHMULTIPLE_TEXT
Definition: shresdef.h:131
#define IDS_TRASHFOLDER_TEXT
Definition: shresdef.h:129
#define IDS_DELETEFOLDER_CAPTION
Definition: shresdef.h:123
#define IDS_DELETEITEM_TEXT
Definition: shresdef.h:124
#define IDI_SHELL_TRASH_FILE
Definition: shresdef.h:616
#define IDS_DELETEMULTIPLE_TEXT
Definition: shresdef.h:125

Referenced by SHELL_ConfirmDialogW().

◆ SHELL_ConfirmMsgBox()

int SHELL_ConfirmMsgBox ( HWND  hWnd,
LPWSTR  lpszText,
LPWSTR  lpszCaption,
HICON  hIcon,
BOOL  bYesToAll 
)

Definition at line 204 of file shlfileop.cpp.

205{
206 struct confirm_msg_info info;
207
208 info.lpszText = lpszText;
209 info.lpszCaption = lpszCaption;
210 info.hIcon = hIcon;
211 info.bYesToAll = bYesToAll;
213}
static INT_PTR CALLBACK ConfirmMsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shlfileop.cpp:186
#define IDD_YESTOALL_MSGBOX
Definition: shresdef.h:428
LPWSTR lpszCaption
Definition: shlfileop.cpp:90
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by SHELL_ConfirmDialogW().

◆ SHELL_ConfirmYesNoW()

BOOL SHELL_ConfirmYesNoW ( HWND  hWnd,
int  nKindOfDialog,
LPCWSTR  szDir 
)

Definition at line 332 of file shlfileop.cpp.

333{
334 return SHELL_ConfirmDialogW(hWnd, nKindOfDialog, szDir, NULL);
335}

◆ SHELL_DeleteDirectoryW()

BOOL SHELL_DeleteDirectoryW ( FILE_OPERATION op,
LPCWSTR  pszDir,
BOOL  bShowUI 
)

Definition at line 370 of file shlfileop.cpp.

371{
372 BOOL ret = TRUE;
373 HANDLE hFind;
375 WCHAR szTemp[MAX_PATH];
376
377 /* Make sure the directory exists before eventually prompting the user */
378 PathCombineW(szTemp, pszDir, L"*");
379 hFind = FindFirstFileW(szTemp, &wfd);
380 if (hFind == INVALID_HANDLE_VALUE)
381 return FALSE;
382
383 if (!bShowUI || (ret = SHELL_ConfirmDialogW(op->req->hwnd, ASK_DELETE_FOLDER, pszDir, NULL)))
384 {
385 do
386 {
387 if (IsDotDir(wfd.cFileName))
388 continue;
389 PathCombineW(szTemp, pszDir, wfd.cFileName);
390 if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
392 else
393 ret = (SHNotifyDeleteFileW(op, szTemp) == ERROR_SUCCESS);
394
395 if (op->progress != NULL)
396 op->bCancelled |= op->progress->HasUserCancelled();
397 } while (ret && FindNextFileW(hFind, &wfd) && !op->bCancelled);
398 }
399 FindClose(hFind);
400 if (ret)
402 return ret;
403}
_In_ LPCSTR pszDir
Definition: shellapi.h:584
static DWORD SHNotifyRemoveDirectoryW(LPCWSTR path)
Definition: shlfileop.cpp:447

Referenced by delete_files(), and SHELL_DeleteDirectoryW().

◆ SHFileOperationA()

int WINAPI SHFileOperationA ( LPSHFILEOPSTRUCTA  lpFileOp)

Definition at line 1060 of file shlfileop.cpp.

1061{
1062 int errCode, retCode;
1063 SHFILEOPSTRUCTW nFileOp = { 0 };
1064
1065 // Convert A information to W
1066 nFileOp.hwnd = lpFileOp->hwnd;
1067 nFileOp.wFunc = lpFileOp->wFunc;
1068 nFileOp.fFlags = lpFileOp->fFlags;
1069
1070 errCode = _ConvertAtoW(lpFileOp->pFrom, &nFileOp.pFrom, TRUE);
1071 if (errCode != 0)
1072 goto cleanup;
1073
1074 if (FO_DELETE != (nFileOp.wFunc & FO_MASK))
1075 {
1076 errCode = _ConvertAtoW(lpFileOp->pTo, &nFileOp.pTo, TRUE);
1077 if (errCode != 0)
1078 goto cleanup;
1079 }
1080
1081 if (nFileOp.fFlags & FOF_SIMPLEPROGRESS)
1082 {
1083 errCode = _ConvertAtoW(lpFileOp->lpszProgressTitle, &nFileOp.lpszProgressTitle, FALSE);
1084 if (errCode != 0)
1085 goto cleanup;
1086 }
1087
1088 // Call the actual function
1089 retCode = SHFileOperationW(&nFileOp);
1090 if (retCode)
1091 {
1092 ERR("SHFileOperationW failed with 0x%x\n", retCode);
1093 }
1094
1095 // Cleanup
1096cleanup:
1097 if (nFileOp.pFrom)
1098 HeapFree(GetProcessHeap(), 0, (PVOID) nFileOp.pFrom);
1099 if (nFileOp.pTo)
1100 HeapFree(GetProcessHeap(), 0, (PVOID) nFileOp.pTo);
1101 if (nFileOp.lpszProgressTitle)
1103
1104 if (errCode != 0)
1105 {
1106 lpFileOp->fAnyOperationsAborted = TRUE;
1107 SetLastError(errCode);
1108
1109 return errCode;
1110 }
1111
1112 // Thankfully, starting with NT4 the name mappings are always unicode, so no need to convert.
1113 lpFileOp->hNameMappings = nFileOp.hNameMappings;
1114 lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
1115 return retCode;
1116}
static void cleanup(void)
Definition: main.c:1335
#define FOF_SIMPLEPROGRESS
Definition: shellapi.h:149
#define FO_MASK
Definition: shlfileop.cpp:34
static DWORD _ConvertAtoW(PCSTR strSrc, PCWSTR *pStrDest, BOOL isList)
Definition: shlfileop.cpp:998
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1988
PVOID hNameMappings
Definition: shellapi.h:351
LPCSTR lpszProgressTitle
Definition: shellapi.h:352
FILEOP_FLAGS fFlags
Definition: shellapi.h:349
BOOL fAnyOperationsAborted
Definition: shellapi.h:350
PVOID hNameMappings
Definition: shellapi.h:361
LPCWSTR pFrom
Definition: shellapi.h:357
BOOL fAnyOperationsAborted
Definition: shellapi.h:360
FILEOP_FLAGS fFlags
Definition: shellapi.h:359
LPCWSTR lpszProgressTitle
Definition: shellapi.h:362

Referenced by delete_cab_files(), delete_pfmsitest_files(), is_old_shell32(), loadShell32(), test_click_make_new_folder_button(), test_copy(), test_delete(), test_move(), and test_rename().

◆ SHFileOperationW()

int WINAPI SHFileOperationW ( LPSHFILEOPSTRUCTW  lpFileOp)

Definition at line 1988 of file shlfileop.cpp.

1989{
1991 FILE_LIST flFrom, flTo;
1992 int ret = 0;
1993
1994 if (!lpFileOp)
1996
1998 if (FAILED(ret))
1999 return ret;
2000
2001 lpFileOp->fAnyOperationsAborted = FALSE;
2002 check_flags(lpFileOp->fFlags);
2003
2004 ZeroMemory(&flFrom, sizeof(FILE_LIST));
2005 ZeroMemory(&flTo, sizeof(FILE_LIST));
2006
2007 if ((ret = parse_file_list(&flFrom, lpFileOp->pFrom)))
2008 return ret;
2009
2010 if (lpFileOp->wFunc != FO_DELETE)
2011 parse_file_list(&flTo, lpFileOp->pTo);
2012
2013 ZeroMemory(&op, sizeof(op));
2014 op.req = lpFileOp;
2015 op.totalSize.QuadPart = 0ull;
2016 op.completedSize.QuadPart = 0ull;
2017 op.bManyItems = (flFrom.dwNumFiles > 1);
2018
2019 ret = validate_operation(lpFileOp, &flFrom, &flTo);
2020 if (ret)
2021 goto cleanup;
2022
2023 if (lpFileOp->wFunc != FO_RENAME && !(lpFileOp->fFlags & FOF_SILENT)) {
2024 ret = CoCreateInstance(CLSID_ProgressDialog,
2025 NULL,
2026 CLSCTX_INPROC_SERVER,
2027 IID_PPV_ARG(IProgressDialog, &op.progress));
2028 if (FAILED(ret))
2029 goto cleanup;
2030
2031 op.progress->StartProgressDialog(op.req->hwnd, NULL, PROGDLG_NORMAL & PROGDLG_AUTOTIME, NULL);
2033 _FileOpCountManager(&op, &flFrom);
2034 }
2035
2036 switch (lpFileOp->wFunc)
2037 {
2038 case FO_COPY:
2039 ret = copy_files(&op, op.req->fFlags & FOF_MULTIDESTFILES, &flFrom, &flTo);
2040 break;
2041 case FO_DELETE:
2042 ret = delete_files(&op, &flFrom);
2043 break;
2044 case FO_MOVE:
2045 ret = move_files(&op, op.req->fFlags & FOF_MULTIDESTFILES, &flFrom, &flTo);
2046 break;
2047 case FO_RENAME:
2048 ret = rename_files(&op, &flFrom, &flTo);
2049 break;
2050 default:
2052 break;
2053 }
2054
2055 if (op.progress) {
2056 op.progress->StopProgressDialog();
2057 op.progress->Release();
2058 }
2059
2060cleanup:
2061 destroy_file_list(&flFrom);
2062
2063 if (lpFileOp->wFunc != FO_DELETE)
2064 destroy_file_list(&flTo);
2065 else if (lpFileOp->fFlags & FOF_ALLOWUNDO)
2067
2068 if (ret == ERROR_CANCELLED)
2069 lpFileOp->fAnyOperationsAborted = TRUE;
2070
2072
2073 return ret;
2074}
EXTERN_C HRESULT WINAPI SHUpdateRecycleBinIcon(void)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define FAILED(hr)
Definition: intsafe.h:51
#define FO_RENAME
Definition: shellapi.h:139
#define FOF_MULTIDESTFILES
Definition: shellapi.h:141
static HRESULT rename_files(FILE_OPERATION *op, const FILE_LIST *flFrom, const FILE_LIST *flTo)
Definition: shlfileop.cpp:1851
static DWORD validate_operation(LPSHFILEOPSTRUCTW lpFileOp, FILE_LIST *flFrom, FILE_LIST *flTo)
Definition: shlfileop.cpp:1890
static void _SetOperationTitle(FILE_OPERATION *op)
Definition: shlfileop.cpp:476
static HRESULT delete_files(FILE_OPERATION *op, const FILE_LIST *flFrom)
Definition: shlfileop.cpp:1585
DWORD WINAPI _FileOpCountManager(FILE_OPERATION *op, const FILE_LIST *flFrom)
Definition: shlfileop.cpp:2313
static void check_flags(FILEOP_FLAGS fFlags)
Definition: shlfileop.cpp:1877
#define PROGDLG_AUTOTIME
Definition: shlobj.h:966
#define PROGDLG_NORMAL
Definition: shlobj.h:964
#define IID_PPV_ARG(Itype, ppType)

Referenced by CFSDropTarget::_CopyItems(), CRecyclerDropTarget::_DoDeleteDataObject(), CFSDropTarget::_DoDrop(), BrFolder_Delete(), cache_container_delete_dir(), DeleteDirectoryTree(), CCopyMoveToMenu::DoRealFileOp(), CMyDocsDropHandler::Drop(), Preview_Delete(), SHELL_SingleFileOperation(), SHFileOperationA(), SHFileOperationWrapW(), and test_unicode().

◆ SHFindAttrW()

static DWORD SHFindAttrW ( LPCWSTR  pName,
BOOL  fileOnly 
)
static

Definition at line 969 of file shlfileop.cpp.

970{
972 BOOL b_FileMask = fileOnly && (NULL != StrPBrkW(pName, L"*?"));
974 HANDLE hFind = FindFirstFileW(pName, &wfd);
975
976 TRACE("%s %d\n", debugstr_w(pName), fileOnly);
977 if (INVALID_HANDLE_VALUE != hFind)
978 {
979 do
980 {
981 if (b_FileMask && IsAttribDir(wfd.dwFileAttributes))
982 continue;
983 dwAttr = wfd.dwFileAttributes;
984 break;
985 } while (FindNextFileW(hFind, &wfd));
986
987 FindClose(hFind);
988 }
989 return dwAttr;
990}
static LPSTR pName
Definition: security.c:75

Referenced by SHNotifyMoveFileW().

◆ SHFreeNameMappings()

void WINAPI SHFreeNameMappings ( HANDLE  hNameMapping)

Definition at line 2099 of file shlfileop.cpp.

2100{
2101 if (hNameMapping)
2102 {
2104 }
2105}
void WINAPI DSA_DestroyCallback(HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dsa.c:432
static int CALLBACK _DestroyCallback(void *p, void *pData)
Definition: shlfileop.cpp:2077
Definition: dsa.c:45

◆ SHIsCdRom()

static BOOL SHIsCdRom ( LPCWSTR  path)
static

Definition at line 753 of file shlfileop.cpp.

754{
755 WCHAR tmp[] = { L"A:\\" };
756
757 if (!path || !path[0])
758 return FALSE;
759
760 if (path[1] != UNICODE_NULL && path[1] != ':')
761 return FALSE;
762
763 tmp[0] = path[0];
764
765 return GetDriveTypeW(tmp) == DRIVE_CDROM;
766}
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_CDROM
Definition: machpc98.h:119
#define UNICODE_NULL

Referenced by SHNotifyCopyFileW().

◆ SHIsFileAvailableOffline()

EXTERN_C HRESULT WINAPI SHIsFileAvailableOffline ( LPCWSTR  path,
LPDWORD  status 
)

Definition at line 358 of file shlfileop.cpp.

359{
360 FIXME("(%s, %p) stub\n", debugstr_w(path), status);
361 return E_FAIL;
362}
#define E_FAIL
Definition: ddrawi.h:102
Definition: ps.c:97

◆ SHNotifyCopyFileW()

static DWORD SHNotifyCopyFileW ( FILE_OPERATION op,
LPCWSTR  src,
LPCWSTR  dest,
BOOL  bFailIfExists 
)
static

Definition at line 782 of file shlfileop.cpp.

783{
784 BOOL ret;
786
787 TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bFailIfExists ? "failIfExists" : "");
788
790
791 /* Destination file may already exist with read only attribute */
795
797 {
800 {
801 TRACE("[shell32, SHNotifyCopyFileW] STILL SHIT\n");
802 }
803 }
804
805 ret = CopyFileExW(src, dest, SHCopyProgressRoutine, op, &op->bCancelled, bFailIfExists);
806 if (ret)
807 {
808 // We are copying from a CD-ROM volume, which is readonly
809 if (SHIsCdRom(src))
810 {
812 attribs &= ~FILE_ATTRIBUTE_READONLY;
814 }
815
817 return ERROR_SUCCESS;
818 }
819
820 return CheckForError(op, GetLastError(), src);
821}
BOOL WINAPI CopyFileExW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL, IN LPVOID lpData OPTIONAL, IN LPBOOL pbCancel OPTIONAL, IN DWORD dwCopyFlags)
Definition: copy.c:318
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
const GLint * attribs
Definition: glext.h:10538
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define IsAttrib(x, y)
Definition: shlfileop.cpp:29
DWORD CALLBACK SHCopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData)
Definition: shlfileop.cpp:559
static DWORD CheckForError(FILE_OPERATION *op, DWORD error, LPCWSTR src)
Definition: shlfileop.cpp:673
static void _SetOperationTexts(FILE_OPERATION *op, LPCWSTR src, LPCWSTR dest)
Definition: shlfileop.cpp:509
static BOOL SHIsCdRom(LPCWSTR path)
Definition: shlfileop.cpp:753
#define SHCNE_CREATE
Definition: shlobj.h:1891

Referenced by copy_file_to_file().

◆ SHNotifyCreateDirectoryW()

static DWORD SHNotifyCreateDirectoryW ( LPCWSTR  path,
LPSECURITY_ATTRIBUTES  sec 
)
static

Definition at line 417 of file shlfileop.cpp.

418{
419 TRACE("(%s, %p)\n", debugstr_w(path), sec);
420
421 if (CreateDirectoryW(path, sec))
422 {
424 return ERROR_SUCCESS;
425 }
426 return GetLastError();
427}
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define SHCNE_MKDIR
Definition: shlobj.h:1893

Referenced by copy_dir_to_dir(), copy_to_dir(), create_dest_dirs(), move_dir_to_dir(), move_to_dir(), SHCreateDirectoryExW(), and Win32CreateDirectoryW().

◆ SHNotifyDeleteFileW()

static DWORD SHNotifyDeleteFileW ( FILE_OPERATION op,
LPCWSTR  path 
)
static

Definition at line 606 of file shlfileop.cpp.

607{
608 BOOL ret;
609
610 TRACE("(%s)\n", debugstr_w(path));
611
613
615 FileSize.QuadPart = 0;
616
619 if (hFile != INVALID_HANDLE_VALUE && IsAttribFile(wfd.dwFileAttributes)) {
620 ULARGE_INTEGER tmp;
621 tmp.u.LowPart = wfd.nFileSizeLow;
622 tmp.u.HighPart = wfd.nFileSizeHigh;
624 }
626
628 if (!ret)
629 {
630 /* File may be write protected or a system file */
631 DWORD dwAttr = GetFileAttributesW(path);
635 }
636 if (ret)
637 {
638 // Bit of a hack to make the progress bar move. We don't have progress inside the file, so inform when done.
641 return ERROR_SUCCESS;
642 }
643 return GetLastError();
644}
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
struct _ULARGE_INTEGER::@4136 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

Referenced by delete_files(), SHELL_DeleteDirectoryW(), and Win32DeleteFileW().

◆ SHNotifyMoveFileW()

static DWORD SHNotifyMoveFileW ( FILE_OPERATION op,
LPCWSTR  src,
LPCWSTR  dest,
BOOL  isdir 
)
static

Definition at line 715 of file shlfileop.cpp.

716{
717 BOOL ret;
718
719 TRACE("(%s %s)\n", debugstr_w(src), debugstr_w(dest));
720
722
724
725 /* MOVEFILE_REPLACE_EXISTING fails with dirs, so try MoveFile */
726 if (!ret)
727 ret = MoveFileW(src, dest);
728
729 if (!ret)
730 {
731 DWORD dwAttr;
732
733 dwAttr = SHFindAttrW(dest, FALSE);
734 if (INVALID_FILE_ATTRIBUTES == dwAttr)
735 {
736 /* Source file may be write protected or a system file */
737 dwAttr = GetFileAttributesW(src);
740 ret = MoveFileW(src, dest);
741 }
742 }
743 if (ret)
744 {
747 return ERROR_SUCCESS;
748 }
749
750 return CheckForError(op, GetLastError(), src);
751}
BOOL WINAPI MoveFileWithProgressW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN LPPROGRESS_ROUTINE lpProgressRoutine, IN LPVOID lpData, IN DWORD dwFlags)
Definition: move.c:718
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1104
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly)
Definition: shlfileop.cpp:969
#define SHCNE_RMDIR
Definition: shlobj.h:1894

Referenced by move_file_to_file(), and rename_files().

◆ SHNotifyRemoveDirectoryW()

static DWORD SHNotifyRemoveDirectoryW ( LPCWSTR  path)
static

Definition at line 447 of file shlfileop.cpp.

448{
449 BOOL ret;
450 TRACE("(%s)\n", debugstr_w(path));
451
453 if (!ret)
454 {
455 /* Directory may be write protected */
456 DWORD dwAttr = GetFileAttributesW(path);
460 }
461 if (ret)
462 {
464 return ERROR_SUCCESS;
465 }
466 return GetLastError();
467}
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732

Referenced by SHELL_DeleteDirectoryW(), and Win32RemoveDirectoryW().

◆ SHPathPrepareForWriteA()

EXTERN_C HRESULT WINAPI SHPathPrepareForWriteA ( HWND  hwnd,
IUnknown modless,
LPCSTR  path,
DWORD  flags 
)

Definition at line 2298 of file shlfileop.cpp.

2299{
2300 WCHAR wpath[MAX_PATH];
2301 MultiByteToWideChar( CP_ACP, 0, path, -1, wpath, MAX_PATH);
2302 return SHPathPrepareForWriteW(hwnd, modless, wpath, flags);
2303}
GLbitfield flags
Definition: glext.h:7161
EXTERN_C HRESULT WINAPI SHPathPrepareForWriteW(HWND hwnd, IUnknown *modless, LPCWSTR path, DWORD flags)
Definition: shlfileop.cpp:2235
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by test_sh_path_prepare().

◆ SHPathPrepareForWriteW()

EXTERN_C HRESULT WINAPI SHPathPrepareForWriteW ( HWND  hwnd,
IUnknown modless,
LPCWSTR  path,
DWORD  flags 
)

Definition at line 2235 of file shlfileop.cpp.

2236{
2237 DWORD res;
2238 DWORD err;
2239 LPCWSTR realpath;
2240 int len;
2241 WCHAR* last_slash;
2242 WCHAR* temppath=NULL;
2243
2244 TRACE("%p %p %s 0x%08x\n", hwnd, modless, debugstr_w(path), flags);
2245
2247 FIXME("unimplemented flags 0x%08x\n", flags);
2248
2249 /* cut off filename if necessary */
2251 {
2252 last_slash = StrRChrW(path, NULL, '\\');
2253 if (last_slash == NULL)
2254 len = 1;
2255 else
2256 len = last_slash - path + 1;
2257 temppath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2258 if (!temppath)
2259 return E_OUTOFMEMORY;
2260 StrCpyNW(temppath, path, len);
2261 realpath = temppath;
2262 }
2263 else
2264 {
2265 realpath = path;
2266 }
2267
2268 /* try to create the directory if asked to */
2270 {
2272 FIXME("treating SHPPFW_ASKDIRCREATE as SHPPFW_DIRCREATE\n");
2273
2274 SHCreateDirectoryExW(0, realpath, NULL);
2275 }
2276
2277 /* check if we can access the directory */
2278 res = GetFileAttributesW(realpath);
2279
2280 HeapFree(GetProcessHeap(), 0, temppath);
2281
2283 {
2284 err = GetLastError();
2287 return HRESULT_FROM_WIN32(err);
2288 }
2289 else if (res & FILE_ATTRIBUTE_DIRECTORY)
2290 return S_OK;
2291 else
2293}
LPWSTR WINAPI StrCpyNW(LPWSTR dst, LPCWSTR src, int count)
Definition: string.c:536
#define SHPPFW_IGNOREFILENAME
Definition: shlobj.h:341
#define SHPPFW_ASKDIRCREATE
Definition: shlobj.h:340
#define SHPPFW_DIRCREATE
Definition: shlobj.h:338
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_DIRECTORY
Definition: winerror.h:295
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by CreateShortcut(), ExtractAndInstallThread(), CZipExtract::ExtractSingle(), SHPathPrepareForWriteA(), and test_sh_path_prepare().

◆ try_find_new_name()

static CStringW try_find_new_name ( LPCWSTR  szDestPath)
static

Definition at line 1297 of file shlfileop.cpp.

1298{
1299 CStringW mask(szDestPath);
1300 CStringW ext(PathFindExtensionW(szDestPath));
1301
1302 // cut off extension before inserting a "new file" mask
1303 if (!ext.IsEmpty())
1304 {
1305 mask = mask.Left(mask.GetLength() - ext.GetLength());
1306 }
1307 mask += L" (%d)" + ext;
1308
1309 CStringW newName;
1310
1311 // trying to find new file name
1312 for (int i = 1; i < NEW_FILENAME_ON_COPY_TRIES; i++)
1313 {
1314 newName.Format(mask, i);
1315
1316 if (!PathFileExistsW(newName))
1317 {
1318 return newName;
1319 }
1320 }
1321
1322 return CStringW();
1323}
static const WCHAR *const ext[]
Definition: module.c:53
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
GLenum GLint GLuint mask
Definition: glext.h:6028
CAtlStringW CStringW
Definition: atlstr.h:130
#define NEW_FILENAME_ON_COPY_TRIES
Definition: shlfileop.cpp:36

Referenced by copy_dir_to_dir(), copy_file_to_file(), and move_file_to_file().

◆ validate_operation()

static DWORD validate_operation ( LPSHFILEOPSTRUCTW  lpFileOp,
FILE_LIST flFrom,
FILE_LIST flTo 
)
static

Definition at line 1890 of file shlfileop.cpp.

1891{
1892 DWORD i, k, dwNumDest;
1893 WCHAR szFrom[MAX_PATH], szTo[MAX_PATH];
1894 CStringW strTitle, strText;
1895 const FILE_ENTRY *feFrom;
1896 const FILE_ENTRY *feTo;
1897 UINT wFunc = lpFileOp->wFunc;
1898 HWND hwnd = lpFileOp->hwnd;
1899
1900 dwNumDest = flTo->dwNumFiles;
1901
1902 if (wFunc != FO_COPY && wFunc != FO_MOVE)
1903 return ERROR_SUCCESS;
1904
1905 for (k = 0; k < dwNumDest; ++k)
1906 {
1907 feTo = &flTo->feFiles[k];
1908 for (i = 0; i < flFrom->dwNumFiles; ++i)
1909 {
1910 feFrom = &flFrom->feFiles[i];
1911 StringCbCopyW(szFrom, sizeof(szFrom), feFrom->szFullPath);
1912 StringCbCopyW(szTo, sizeof(szTo), feTo->szFullPath);
1913 if (IsAttribDir(feTo->attributes))
1914 {
1915 PathAppendW(szTo, feFrom->szFilename);
1916 }
1917
1918 // same path?
1919 if (lstrcmpiW(szFrom, szTo) == 0 &&
1920 (wFunc == FO_MOVE || !(lpFileOp->fFlags & FOF_RENAMEONCOLLISION)))
1921 {
1922 if (!(lpFileOp->fFlags & (FOF_NOERRORUI | FOF_SILENT)))
1923 {
1924 if (wFunc == FO_MOVE)
1925 {
1926 strTitle.LoadStringW(IDS_MOVEERRORTITLE);
1927 if (IsAttribDir(feFrom->attributes))
1929 else
1930 strText.Format(IDS_MOVEERRORSAME, GET_FILENAME(feFrom));
1931 }
1932 else
1933 {
1934 strTitle.LoadStringW(IDS_COPYERRORTITLE);
1935 strText.Format(IDS_COPYERRORSAME, GET_FILENAME(feFrom));
1936 return ERROR_SUCCESS;
1937 }
1938 MessageBoxW(hwnd, strText, strTitle, MB_ICONERROR);
1939 return DE_SAMEFILE;
1940 }
1941 return DE_OPCANCELLED;
1942 }
1943
1944 // subfolder?
1945 if (IsAttribDir(feFrom->attributes))
1946 {
1947 size_t cchFrom = PathAddBackslashW(szFrom) - szFrom;
1948 size_t cchTo = PathAddBackslashW(szTo) - szTo;
1949 if (cchFrom < cchTo)
1950 {
1951 WCHAR ch = szTo[cchFrom];
1952 szTo[cchFrom] = 0;
1953 int compare = lstrcmpiW(szFrom, szTo);
1954 szTo[cchFrom] = ch;
1955
1956 if (compare == 0)
1957 {
1958 if (!(lpFileOp->fFlags & (FOF_NOERRORUI | FOF_SILENT)))
1959 {
1960 if (wFunc == FO_MOVE)
1961 {
1962 strTitle.LoadStringW(IDS_MOVEERRORTITLE);
1963 strText.Format(IDS_MOVEERRORSUBFOLDER, GET_FILENAME(feFrom));
1964 }
1965 else
1966 {
1967 strTitle.LoadStringW(IDS_COPYERRORTITLE);
1968 strText.Format(IDS_COPYERRORSUBFOLDER, GET_FILENAME(feFrom));
1969 }
1970 MessageBoxW(hwnd, strText, strTitle, MB_ICONERROR);
1971 return DE_DESTSUBTREE;
1972 }
1973 return DE_OPCANCELLED;
1974 }
1975 }
1976 }
1977 }
1978 }
1979
1980 return ERROR_SUCCESS;
1981}
int k
Definition: mpi.c:3369
#define PathAppendW
Definition: pathcch.h:309
#define DE_DESTSUBTREE
Definition: shlfileop.c:46
#define DE_OPCANCELLED
Definition: shlfileop.c:45
#define GET_FILENAME(fe)
Definition: shlfileop.cpp:1887
#define IDS_MOVEERRORSUBFOLDER
Definition: shresdef.h:256
#define IDS_COPYERRORSUBFOLDER
Definition: shresdef.h:257
#define IDS_MOVEERRORSAME
Definition: shresdef.h:254
#define IDS_COPYERRORSAME
Definition: shresdef.h:255
#define IDS_MOVEERRORSAMEFOLDER
Definition: shresdef.h:253
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
Definition: bug.cpp:8

Referenced by SHFileOperationW().

◆ wildcard_to_file()

static LPWSTR wildcard_to_file ( LPCWSTR  szWildCard,
LPCWSTR  szFileName 
)
static

Definition at line 1154 of file shlfileop.cpp.

1155{
1156 LPCWSTR ptr;
1157 LPCWSTR ptr2;
1158 LPWSTR szFullPath;
1159 DWORD dwDirLen, dwFullLen;
1160
1161 ptr = StrRChrW(szWildCard, NULL, '\\');
1162 ptr2 = StrRChrW(szWildCard, NULL, '/');
1163 if (!ptr || ptr < ptr2)
1164 ptr = ptr2;
1165 dwDirLen = ptr - szWildCard + 1;
1166
1167 dwFullLen = dwDirLen + lstrlenW(szFileName) + 1;
1168 szFullPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwFullLen * sizeof(WCHAR));
1169
1170 lstrcpynW(szFullPath, szWildCard, dwDirLen + 1);
1171 lstrcatW(szFullPath, szFileName);
1172
1173 return szFullPath;
1174}
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by parse_wildcard_files().

◆ Win32CreateDirectoryW()

EXTERN_C BOOL WINAPI Win32CreateDirectoryW ( LPCWSTR  path,
LPSECURITY_ATTRIBUTES  sec 
)

Definition at line 431 of file shlfileop.cpp.

432{
434}

◆ Win32DeleteFileW()

EXTERN_C DWORD WINAPI Win32DeleteFileW ( LPCWSTR  path)

Definition at line 657 of file shlfileop.cpp.

658{
660}

◆ Win32RemoveDirectoryW()

EXTERN_C BOOL WINAPI Win32RemoveDirectoryW ( LPCWSTR  path)

Definition at line 471 of file shlfileop.cpp.

472{
474}

Referenced by move_dir_to_dir().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )