4 * Copyright 2000 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "shell32_main.h"
27 #include "undocshell.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
33 BOOL
SHELL_WarnItemDelete (int nKindOfDialog
, LPCSTR szDir
)
35 char szCaption
[255], szText
[255], szBuffer
[MAX_PATH
+ 256];
37 if(nKindOfDialog
== ASK_DELETE_FILE
)
39 LoadStringA(shell32_hInstance
, IDS_DELETEITEM_TEXT
, szText
,
41 LoadStringA(shell32_hInstance
, IDS_DELETEITEM_CAPTION
,
42 szCaption
, sizeof(szCaption
));
44 else if(nKindOfDialog
== ASK_DELETE_FOLDER
)
46 LoadStringA(shell32_hInstance
, IDS_DELETEITEM_TEXT
, szText
,
48 LoadStringA(shell32_hInstance
, IDS_DELETEFOLDER_CAPTION
,
49 szCaption
, sizeof(szCaption
));
51 else if(nKindOfDialog
== ASK_DELETE_MULTIPLE_ITEM
)
53 LoadStringA(shell32_hInstance
, IDS_DELETEMULTIPLE_TEXT
, szText
,
55 LoadStringA(shell32_hInstance
, IDS_DELETEITEM_CAPTION
,
56 szCaption
, sizeof(szCaption
));
59 FIXME("Called without a valid nKindOfDialog specified!\n");
60 LoadStringA(shell32_hInstance
, IDS_DELETEITEM_TEXT
, szText
,
62 LoadStringA(shell32_hInstance
, IDS_DELETEITEM_CAPTION
,
63 szCaption
, sizeof(szCaption
));
66 FormatMessageA(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
67 szText
, 0, 0, szBuffer
, sizeof(szBuffer
), (va_list*)&szDir
);
69 return (IDOK
== MessageBoxA(GetActiveWindow(), szBuffer
, szCaption
, MB_OKCANCEL
| MB_ICONEXCLAMATION
));
72 /**************************************************************************
73 * SHELL_DeleteDirectoryA()
78 BOOL
SHELL_DeleteDirectoryA(LPCSTR pszDir
, BOOL bShowUI
)
83 char szTemp
[MAX_PATH
];
85 strcpy(szTemp
, pszDir
);
86 PathAddBackslashA(szTemp
);
87 strcat(szTemp
, "*.*");
89 if (bShowUI
&& !SHELL_WarnItemDelete(ASK_DELETE_FOLDER
, pszDir
))
92 if(INVALID_HANDLE_VALUE
!= (hFind
= FindFirstFileA(szTemp
, &wfd
)))
96 if(strcasecmp(wfd
.cFileName
, ".") && strcasecmp(wfd
.cFileName
, ".."))
98 strcpy(szTemp
, pszDir
);
99 PathAddBackslashA(szTemp
);
100 strcat(szTemp
, wfd
.cFileName
);
102 if(FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
103 SHELL_DeleteDirectoryA(szTemp
, FALSE
);
107 } while(FindNextFileA(hFind
, &wfd
));
110 ret
= RemoveDirectoryA(pszDir
);
116 /**************************************************************************
117 * SHELL_DeleteFileA()
120 BOOL
SHELL_DeleteFileA(LPCSTR pszFile
, BOOL bShowUI
)
122 if (bShowUI
&& !SHELL_WarnItemDelete(ASK_DELETE_FILE
, pszFile
))
125 return DeleteFileA(pszFile
);
128 /*************************************************************************
129 * SHCreateDirectory [SHELL32.165]
132 * exported by ordinal
133 * not sure about LPSECURITY_ATTRIBUTES
135 DWORD WINAPI
SHCreateDirectory(LPSECURITY_ATTRIBUTES sec
,LPCSTR path
)
138 TRACE("(%p,%s)\n",sec
,path
);
139 if ((ret
= CreateDirectoryA(path
,sec
)))
141 SHChangeNotifyA(SHCNE_MKDIR
, SHCNF_PATHA
, path
, NULL
);
146 /************************************************************************
147 * Win32DeleteFile [SHELL32.164]
149 * Deletes a file. Also triggers a change notify if one exists.
152 * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be
153 * ANSI. Is this Unicode on NT?
157 BOOL WINAPI
Win32DeleteFile(LPSTR fName
)
159 TRACE("%p(%s)\n", fName
, fName
);
162 SHChangeNotifyA(SHCNE_DELETE
, SHCNF_PATHA
, fName
, NULL
);
166 /*************************************************************************
167 * SHFileOperationA [SHELL32.@]
172 DWORD WINAPI
SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp
)
174 LPSTR pFrom
= (LPSTR
)lpFileOp
->pFrom
;
175 LPSTR pTo
= (LPSTR
)lpFileOp
->pTo
;
177 TRACE("flags (0x%04x) : %s%s%s%s%s%s%s%s%s%s%s%s \n", lpFileOp
->fFlags
,
178 lpFileOp
->fFlags
& FOF_MULTIDESTFILES
? "FOF_MULTIDESTFILES " : "",
179 lpFileOp
->fFlags
& FOF_CONFIRMMOUSE
? "FOF_CONFIRMMOUSE " : "",
180 lpFileOp
->fFlags
& FOF_SILENT
? "FOF_SILENT " : "",
181 lpFileOp
->fFlags
& FOF_RENAMEONCOLLISION
? "FOF_RENAMEONCOLLISION " : "",
182 lpFileOp
->fFlags
& FOF_NOCONFIRMATION
? "FOF_NOCONFIRMATION " : "",
183 lpFileOp
->fFlags
& FOF_WANTMAPPINGHANDLE
? "FOF_WANTMAPPINGHANDLE " : "",
184 lpFileOp
->fFlags
& FOF_ALLOWUNDO
? "FOF_ALLOWUNDO " : "",
185 lpFileOp
->fFlags
& FOF_FILESONLY
? "FOF_FILESONLY " : "",
186 lpFileOp
->fFlags
& FOF_SIMPLEPROGRESS
? "FOF_SIMPLEPROGRESS " : "",
187 lpFileOp
->fFlags
& FOF_NOCONFIRMMKDIR
? "FOF_NOCONFIRMMKDIR " : "",
188 lpFileOp
->fFlags
& FOF_NOERRORUI
? "FOF_NOERRORUI " : "",
189 lpFileOp
->fFlags
& 0xf800 ? "MORE-UNKNOWN-Flags" : "");
190 switch(lpFileOp
->wFunc
) {
192 /* establish when pTo is interpreted as the name of the destination file
193 * or the directory where the Fromfile should be copied to.
195 * (1) pTo points to the name of an existing directory;
196 * (2) the flag FOF_MULTIDESTFILES is present;
197 * (3) whether pFrom point to multiple filenames.
201 * destisdir 1 1 1 1 0 0 0 0
202 * FOF_MULTIDESTFILES 1 1 0 0 1 1 0 0
203 * multiple from filenames 1 0 1 0 1 0 1 0
205 * copy files to dir 1 0 1 1 0 0 1 0
206 * create dir 0 0 0 0 0 0 1 0
208 int multifrom
= pFrom
[strlen(pFrom
) + 1] != '\0';
209 int destisdir
= PathIsDirectoryA( pTo
);
211 TRACE("File Copy:\n");
213 if ( !((lpFileOp
->fFlags
& FOF_MULTIDESTFILES
) && !multifrom
))
216 if ( !(lpFileOp
->fFlags
& FOF_MULTIDESTFILES
) && multifrom
)
223 TRACE(" creating directory %s\n",pTo
);
224 SHCreateDirectory(NULL
,pTo
);
226 lenPTo
= strlen(pTo
);
229 fromfile
= PathFindFileNameA( pFrom
);
230 pTempTo
= HeapAlloc(GetProcessHeap(), 0, lenPTo
+ strlen(fromfile
) + 2);
233 if(lenPTo
&& pTo
[lenPTo
] != '\\')
234 strcat(pTempTo
,"\\");
235 strcat(pTempTo
,fromfile
);
236 TRACE(" From='%s' To='%s'\n", pFrom
, pTempTo
);
237 CopyFileA(pFrom
, pTempTo
, FALSE
);
238 HeapFree(GetProcessHeap(), 0, pTempTo
);
240 pFrom
+= strlen(pFrom
) + 1;
246 TRACE(" From='%s' To='%s'\n", pFrom
, pTo
);
248 pTempTo
= HeapAlloc(GetProcessHeap(), 0, strlen(pTo
)+1);
251 strcpy( pTempTo
, pTo
);
252 PathRemoveFileSpecA(pTempTo
);
253 TRACE(" Creating Directory '%s'\n", pTempTo
);
254 SHCreateDirectory(NULL
,pTempTo
);
255 HeapFree(GetProcessHeap(), 0, pTempTo
);
257 CopyFileA(pFrom
, pTo
, FALSE
);
259 pFrom
+= strlen(pFrom
) + 1;
260 pTo
+= strlen(pTo
) + 1;
263 TRACE("Setting AnyOpsAborted=FALSE\n");
264 lpFileOp
->fAnyOperationsAborted
=FALSE
;
269 TRACE("File Delete:\n");
272 TRACE(" File='%s'\n", pFrom
);
274 pFrom
+= strlen(pFrom
) + 1;
276 TRACE("Setting AnyOpsAborted=FALSE\n");
277 lpFileOp
->fAnyOperationsAborted
=FALSE
;
281 FIXME("Unhandled shell file operation %d\n", lpFileOp
->wFunc
);
287 /*************************************************************************
288 * SHFileOperationW [SHELL32.@]
293 DWORD WINAPI
SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp
)
295 FIXME("(%p):stub.\n", lpFileOp
);
299 /*************************************************************************
300 * SHFileOperation [SHELL32.@]
303 DWORD WINAPI
SHFileOperationAW(LPVOID lpFileOp
)
305 if (SHELL_OsIsUnicode())
306 return SHFileOperationW(lpFileOp
);
307 return SHFileOperationA(lpFileOp
);
310 /*************************************************************************
311 * SheGetDirW [SHELL32.281]
314 HRESULT WINAPI
SheGetDirW(LPWSTR u
, LPWSTR v
)
315 { FIXME("%p %p stub\n",u
,v
);
319 /*************************************************************************
320 * SheChangeDirW [SHELL32.274]
323 HRESULT WINAPI
SheChangeDirW(LPWSTR u
)
324 { FIXME("(%s),stub\n",debugstr_w(u
));
328 /*************************************************************************
329 * IsNetDrive [SHELL32.66]
331 BOOL WINAPI
IsNetDrive(DWORD drive
)
334 strcpy(root
, "A:\\");
336 return (GetDriveTypeA(root
) == DRIVE_REMOTE
);