Explicit import user32.dll.
[wine] / dlls / shell32 / shlfileop.c
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"
9
10 #include "shlobj.h"
11
12 DEFAULT_DEBUG_CHANNEL(shell);
13
14 /**************************************************************************
15  *      SHELL_DeleteDirectoryA()
16  *
17  * like rm -r
18  */
19
20 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir)
21 {
22         BOOL            ret = FALSE;
23         HANDLE          hFind;
24         WIN32_FIND_DATAA wfd;
25         char            szTemp[MAX_PATH];
26
27         strcpy(szTemp, pszDir);
28         PathAddBackslashA(szTemp);
29         strcat(szTemp, "*.*");
30         
31         if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd)))
32         {
33           do
34           {
35             if(strcasecmp(wfd.cFileName, ".") && strcasecmp(wfd.cFileName, ".."))
36             {
37               strcpy(szTemp, pszDir);
38               PathAddBackslashA(szTemp);
39               strcat(szTemp, wfd.cFileName);
40         
41               if(FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
42                 SHELL_DeleteDirectoryA(szTemp);
43               else
44                 DeleteFileA(szTemp);
45             }
46           } while(FindNextFileA(hFind, &wfd));
47
48           FindClose(hFind);
49           ret = RemoveDirectoryA(pszDir);
50         }
51
52         return ret;
53 }
54
55 /*************************************************************************
56  * SHCreateDirectory                            [SHELL32.165]
57  *
58  * NOTES
59  *  exported by ordinal
60  *  not sure about LPSECURITY_ATTRIBUTES
61  */
62 DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path)
63 {
64         DWORD ret;
65         TRACE("(%p,%s)\n",sec,path);
66         if ((ret = CreateDirectoryA(path,sec)))
67         {
68           SHChangeNotifyA(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
69         }
70         return ret;
71 }
72
73 /************************************************************************
74  *      Win32DeleteFile                         [SHELL32.164]  
75  *
76  * Deletes a file.  Also triggers a change notify if one exists.
77  *
78  * FIXME:
79  * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be
80  * ANSI.  Is this Unicode on NT?
81  *
82  */ 
83
84 BOOL WINAPI Win32DeleteFile(LPSTR fName)
85 {
86         TRACE("%p(%s)\n", fName, fName);
87
88         DeleteFileA(fName);
89         SHChangeNotifyA(SHCNE_DELETE, SHCNF_PATHA, fName, NULL);
90         return TRUE;
91 }
92
93 /*************************************************************************
94  * SHFileOperationA                             [SHELL32.243]
95  *
96  * NOTES
97  *     exported by name
98  */
99 DWORD WINAPI SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp)   
100 {
101         FIXME("(%p):stub.\n", lpFileOp);
102         return 1;
103 }
104
105 /*************************************************************************
106  * SHFileOperationW                             [SHELL32.244]
107  *
108  * NOTES
109  *     exported by name
110  */
111 DWORD WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)   
112 {
113         FIXME("(%p):stub.\n", lpFileOp);
114         return 1;
115 }
116
117 /*************************************************************************
118  * SHFileOperation                              [SHELL32.242]
119  *
120  */
121 DWORD WINAPI SHFileOperationAW(LPVOID lpFileOp)
122 {
123         if (VERSION_OsIsUnicode())
124           return SHFileOperationW(lpFileOp);
125         return SHFileOperationA(lpFileOp);
126 }