fixed a number of long standing bugs:
[wine/multimedia.git] / dlls / shell32 / shlfileop.c
blobc73fb532179e09a822eb0b6158b257a6ee9d425e
1 /*
2 * SHFileOperation
3 */
4 #include <string.h>
5 #include "debugtools.h"
6 #include "shellapi.h"
7 #include "shell32_main.h"
8 #include "winversion.h"
10 #include "shlobj.h"
11 #include "shresdef.h"
12 #include "wine/undocshell.h"
14 DEFAULT_DEBUG_CHANNEL(shell);
16 #define ASK_DELETE_FILE 1
17 #define ASK_DELETE_FOLDER 2
18 #define ASK_DELETE_MULTIPLE_FILE 3
20 static BOOL SHELL_WarnFolderDelete (int nKindOfDialog, LPCSTR szDir)
22 char szCaption[255], szText[255], szBuffer[256];
24 LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_TEXT, szText, sizeof(szText));
25 LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION, szCaption, sizeof(szCaption));
26 FormatMessageA(FORMAT_MESSAGE_FROM_STRING, szText, 0,0, szBuffer, sizeof(szBuffer), (DWORD*)&szDir);
28 return (IDOK == MessageBoxA(GetActiveWindow(),szText, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
31 /**************************************************************************
32 * SHELL_DeleteDirectoryA()
34 * like rm -r
37 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
39 BOOL ret = FALSE;
40 HANDLE hFind;
41 WIN32_FIND_DATAA wfd;
42 char szTemp[MAX_PATH];
44 strcpy(szTemp, pszDir);
45 PathAddBackslashA(szTemp);
46 strcat(szTemp, "*.*");
48 if (bShowUI && !SHELL_WarnFolderDelete(ASK_DELETE_FOLDER, pszDir)) return FALSE;
50 if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd)))
54 if(strcasecmp(wfd.cFileName, ".") && strcasecmp(wfd.cFileName, ".."))
56 strcpy(szTemp, pszDir);
57 PathAddBackslashA(szTemp);
58 strcat(szTemp, wfd.cFileName);
60 if(FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
61 SHELL_DeleteDirectoryA(szTemp, FALSE);
62 else
63 DeleteFileA(szTemp);
65 } while(FindNextFileA(hFind, &wfd));
67 FindClose(hFind);
68 ret = RemoveDirectoryA(pszDir);
71 return ret;
74 /*************************************************************************
75 * SHCreateDirectory [SHELL32.165]
77 * NOTES
78 * exported by ordinal
79 * not sure about LPSECURITY_ATTRIBUTES
81 DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path)
83 DWORD ret;
84 TRACE("(%p,%s)\n",sec,path);
85 if ((ret = CreateDirectoryA(path,sec)))
87 SHChangeNotifyA(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
89 return ret;
92 /************************************************************************
93 * Win32DeleteFile [SHELL32.164]
95 * Deletes a file. Also triggers a change notify if one exists.
97 * FIXME:
98 * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be
99 * ANSI. Is this Unicode on NT?
103 BOOL WINAPI Win32DeleteFile(LPSTR fName)
105 TRACE("%p(%s)\n", fName, fName);
107 DeleteFileA(fName);
108 SHChangeNotifyA(SHCNE_DELETE, SHCNF_PATHA, fName, NULL);
109 return TRUE;
112 /*************************************************************************
113 * SHFileOperationA [SHELL32.243]
115 * NOTES
116 * exported by name
118 DWORD WINAPI SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp)
120 FIXME("(%p):stub.\n", lpFileOp);
121 return 1;
124 /*************************************************************************
125 * SHFileOperationW [SHELL32.244]
127 * NOTES
128 * exported by name
130 DWORD WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)
132 FIXME("(%p):stub.\n", lpFileOp);
133 return 1;
136 /*************************************************************************
137 * SHFileOperation [SHELL32.242]
140 DWORD WINAPI SHFileOperationAW(LPVOID lpFileOp)
142 if (VERSION_OsIsUnicode())
143 return SHFileOperationW(lpFileOp);
144 return SHFileOperationA(lpFileOp);
147 /*************************************************************************
148 * SheGetDirW [SHELL32.281]
151 HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
152 { FIXME("%p %p stub\n",u,v);
153 return 0;
156 /*************************************************************************
157 * SheChangeDirW [SHELL32.274]
160 HRESULT WINAPI SheChangeDirW(LPWSTR u)
161 { FIXME("(%s),stub\n",debugstr_w(u));
162 return 0;