10 #include "shell32_main.h"
11 #include "undocshell.h"
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(shell);
17 BOOL SHELL_WarnItemDelete (int nKindOfDialog, LPCSTR szDir)
19 char szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
21 if(nKindOfDialog == ASK_DELETE_FILE)
23 LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
25 LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
26 szCaption, sizeof(szCaption));
28 else if(nKindOfDialog == ASK_DELETE_FOLDER)
30 LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
32 LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION,
33 szCaption, sizeof(szCaption));
35 else if(nKindOfDialog == ASK_DELETE_MULTIPLE_ITEM)
37 LoadStringA(shell32_hInstance, IDS_DELETEMULTIPLE_TEXT, szText,
39 LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
40 szCaption, sizeof(szCaption));
43 FIXME("Called without a valid nKindOfDialog specified!\n");
44 LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
46 LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
47 szCaption, sizeof(szCaption));
50 FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
51 szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
53 return (IDOK == MessageBoxA(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
56 /**************************************************************************
57 * SHELL_DeleteDirectoryA()
62 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
67 char szTemp[MAX_PATH];
69 strcpy(szTemp, pszDir);
70 PathAddBackslashA(szTemp);
71 strcat(szTemp, "*.*");
73 if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FOLDER, pszDir))
76 if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd)))
80 if(strcasecmp(wfd.cFileName, ".") && strcasecmp(wfd.cFileName, ".."))
82 strcpy(szTemp, pszDir);
83 PathAddBackslashA(szTemp);
84 strcat(szTemp, wfd.cFileName);
86 if(FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
87 SHELL_DeleteDirectoryA(szTemp, FALSE);
91 } while(FindNextFileA(hFind, &wfd));
94 ret = RemoveDirectoryA(pszDir);
100 /**************************************************************************
101 * SHELL_DeleteFileA()
104 BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI)
106 if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FILE, pszFile))
109 return DeleteFileA(pszFile);
112 /*************************************************************************
113 * SHCreateDirectory [SHELL32.165]
116 * exported by ordinal
117 * not sure about LPSECURITY_ATTRIBUTES
119 DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path)
122 TRACE("(%p,%s)\n",sec,path);
123 if ((ret = CreateDirectoryA(path,sec)))
125 SHChangeNotifyA(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
130 /************************************************************************
131 * Win32DeleteFile [SHELL32.164]
133 * Deletes a file. Also triggers a change notify if one exists.
136 * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be
137 * ANSI. Is this Unicode on NT?
141 BOOL WINAPI Win32DeleteFile(LPSTR fName)
143 TRACE("%p(%s)\n", fName, fName);
146 SHChangeNotifyA(SHCNE_DELETE, SHCNF_PATHA, fName, NULL);
150 /*************************************************************************
151 * SHFileOperationA [SHELL32.@]
156 DWORD WINAPI SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp)
158 LPSTR pFrom = (LPSTR)lpFileOp->pFrom;
159 LPSTR pTo = (LPSTR)lpFileOp->pTo;
161 TRACE("flags (0x%04x) : %s%s%s%s%s%s%s%s%s%s%s%s \n", lpFileOp->fFlags,
162 lpFileOp->fFlags & FOF_MULTIDESTFILES ? "FOF_MULTIDESTFILES " : "",
163 lpFileOp->fFlags & FOF_CONFIRMMOUSE ? "FOF_CONFIRMMOUSE " : "",
164 lpFileOp->fFlags & FOF_SILENT ? "FOF_SILENT " : "",
165 lpFileOp->fFlags & FOF_RENAMEONCOLLISION ? "FOF_RENAMEONCOLLISION " : "",
166 lpFileOp->fFlags & FOF_NOCONFIRMATION ? "FOF_NOCONFIRMATION " : "",
167 lpFileOp->fFlags & FOF_WANTMAPPINGHANDLE ? "FOF_WANTMAPPINGHANDLE " : "",
168 lpFileOp->fFlags & FOF_ALLOWUNDO ? "FOF_ALLOWUNDO " : "",
169 lpFileOp->fFlags & FOF_FILESONLY ? "FOF_FILESONLY " : "",
170 lpFileOp->fFlags & FOF_SIMPLEPROGRESS ? "FOF_SIMPLEPROGRESS " : "",
171 lpFileOp->fFlags & FOF_NOCONFIRMMKDIR ? "FOF_NOCONFIRMMKDIR " : "",
172 lpFileOp->fFlags & FOF_NOERRORUI ? "FOF_NOERRORUI " : "",
173 lpFileOp->fFlags & 0xf800 ? "MORE-UNKNOWN-Flags" : "");
174 switch(lpFileOp->wFunc) {
176 /* establish when pTo is interpreted as the name of the destination file
177 * or the directory where the Fromfile should be copied to.
179 * (1) pTo points to the name of an existing directory;
180 * (2) the flag FOF_MULTIDESTFILES is present;
181 * (3) whether pFrom point to multiple filenames.
185 * destisdir 1 1 1 1 0 0 0 0
186 * FOF_MULTIDESTFILES 1 1 0 0 1 1 0 0
187 * multiple from filenames 1 0 1 0 1 0 1 0
189 * copy files to dir 1 0 1 1 0 0 1 0
190 * create dir 0 0 0 0 0 0 1 0
192 int multifrom = pFrom[strlen(pFrom) + 1] != '\0';
193 int destisdir = PathIsDirectoryA( pTo );
195 TRACE("File Copy:\n");
197 if ( !((lpFileOp->fFlags & FOF_MULTIDESTFILES) && !multifrom))
200 if ( !(lpFileOp->fFlags & FOF_MULTIDESTFILES) && multifrom)
207 TRACE(" creating directory %s\n",pTo);
208 SHCreateDirectory(NULL,pTo);
210 lenPTo = strlen(pTo);
213 fromfile = PathFindFileNameA( pFrom);
214 pTempTo = HeapAlloc(GetProcessHeap(), 0, lenPTo + strlen(fromfile) + 2);
217 if(lenPTo && pTo[lenPTo] != '\\')
218 strcat(pTempTo,"\\");
219 strcat(pTempTo,fromfile);
220 TRACE(" From='%s' To='%s'\n", pFrom, pTempTo);
221 CopyFileA(pFrom, pTempTo, FALSE);
222 HeapFree(GetProcessHeap(), 0, pTempTo);
224 pFrom += strlen(pFrom) + 1;
230 TRACE(" From='%s' To='%s'\n", pFrom, pTo);
232 pTempTo = HeapAlloc(GetProcessHeap(), 0, strlen(pTo)+1);
235 strcpy( pTempTo, pTo );
236 PathRemoveFileSpecA(pTempTo);
237 TRACE(" Creating Directory '%s'\n", pTempTo);
238 SHCreateDirectory(NULL,pTempTo);
239 HeapFree(GetProcessHeap(), 0, pTempTo);
241 CopyFileA(pFrom, pTo, FALSE);
243 pFrom += strlen(pFrom) + 1;
244 pTo += strlen(pTo) + 1;
247 TRACE("Setting AnyOpsAborted=FALSE\n");
248 lpFileOp->fAnyOperationsAborted=FALSE;
253 TRACE("File Delete:\n");
256 TRACE(" File='%s'\n", pFrom);
258 pFrom += strlen(pFrom) + 1;
260 TRACE("Setting AnyOpsAborted=FALSE\n");
261 lpFileOp->fAnyOperationsAborted=FALSE;
265 FIXME("Unhandled shell file operation %d\n", lpFileOp->wFunc);
271 /*************************************************************************
272 * SHFileOperationW [SHELL32.@]
277 DWORD WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)
279 FIXME("(%p):stub.\n", lpFileOp);
283 /*************************************************************************
284 * SHFileOperation [SHELL32.@]
287 DWORD WINAPI SHFileOperationAW(LPVOID lpFileOp)
289 if (SHELL_OsIsUnicode())
290 return SHFileOperationW(lpFileOp);
291 return SHFileOperationA(lpFileOp);
294 /*************************************************************************
295 * SheGetDirW [SHELL32.281]
298 HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
299 { FIXME("%p %p stub\n",u,v);
303 /*************************************************************************
304 * SheChangeDirW [SHELL32.274]
307 HRESULT WINAPI SheChangeDirW(LPWSTR u)
308 { FIXME("(%s),stub\n",debugstr_w(u));
312 /*************************************************************************
313 * IsNetDrive [SHELL32.66]
315 BOOL WINAPI IsNetDrive(DWORD drive)
318 strcpy(root, "A:\\");
320 return (GetDriveTypeA(root) == DRIVE_REMOTE);