ReactOS 0.4.15-dev-8235-gcd88a97
recyclebin.c File Reference
Include dependency graph for recyclebin.c:

Go to the source code of this file.

Functions

BOOL WINAPI CloseRecycleBinHandle (IN HDELFILE hDeletedFile)
 
BOOL WINAPI DeleteFileToRecycleBinA (IN LPCSTR FileName)
 
BOOL WINAPI DeleteFileToRecycleBinW (IN LPCWSTR FileName)
 
BOOL WINAPI DeleteFileHandleToRecycleBin (IN HDELFILE hDeletedFile)
 
BOOL WINAPI EmptyRecycleBinA (IN LPCSTR pszRoot OPTIONAL)
 
BOOL WINAPI EmptyRecycleBinW (IN LPCWSTR pszRoot OPTIONAL)
 
BOOL WINAPI EnumerateRecycleBinA (IN LPCSTR pszRoot OPTIONAL, IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context OPTIONAL)
 
BOOL WINAPI EnumerateRecycleBinW (IN LPCWSTR pszRoot OPTIONAL, IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context OPTIONAL)
 
BOOL WINAPI GetDeletedFileTypeNameW (IN HDELFILE hDeletedFile, OUT LPWSTR pTypeName, IN DWORD BufferSize, OUT LPDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI GetDeletedFileDetailsA (IN HDELFILE hDeletedFile, IN DWORD BufferSize, IN OUT PDELETED_FILE_DETAILS_A FileDetails OPTIONAL, OUT LPDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI GetDeletedFileDetailsW (IN HDELFILE hDeletedFile, IN DWORD BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL, OUT LPDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI RestoreFile (IN HDELFILE hDeletedFile)
 
HRESULT WINAPI GetDefaultRecycleBin (IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
 

Function Documentation

◆ CloseRecycleBinHandle()

BOOL WINAPI CloseRecycleBinHandle ( IN HDELFILE  hDeletedFile)

Definition at line 12 of file recyclebin.c.

14{
15 IRecycleBinFile *rbf = (IRecycleBinFile *)hDeletedFile;
16 HRESULT hr;
17
18 TRACE("(%p)\n", hDeletedFile);
19
20 hr = IRecycleBinFile_Release(rbf);
21 if (SUCCEEDED(hr))
22 return TRUE;
25 else
27 return FALSE;
28}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
#define HRESULT_FACILITY(hr)
Definition: winerror.h:79
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define FACILITY_WIN32
Definition: winerror.h:27
#define HRESULT_CODE(hr)
Definition: winerror.h:76

Referenced by CRecycleBinEnum::CBEnumRecycleBin(), CBSearchRecycleBin(), CRecyclerExtractIcon_CreateInstance(), CRecycleBin::GetDetailsOf(), and CRecycleBinItemContextMenu::InvokeCommand().

◆ DeleteFileHandleToRecycleBin()

BOOL WINAPI DeleteFileHandleToRecycleBin ( IN HDELFILE  hDeletedFile)

Definition at line 93 of file recyclebin.c.

95{
96 IRecycleBinFile *rbf = (IRecycleBinFile *)hDeletedFile;
97 HRESULT hr;
98
99 TRACE("(%p)\n", hDeletedFile);
100
101 hr = IRecycleBinFile_Delete(rbf);
102
103 if (SUCCEEDED(hr))
104 return TRUE;
107 else
109 return FALSE;
110}

Referenced by CRecycleBinItemContextMenu::InvokeCommand().

◆ DeleteFileToRecycleBinA()

BOOL WINAPI DeleteFileToRecycleBinA ( IN LPCSTR  FileName)

Definition at line 31 of file recyclebin.c.

33{
34 int len;
35 LPWSTR FileNameW = NULL;
36 BOOL ret = FALSE;
37
38 TRACE("(%s)\n", debugstr_a(FileName));
39
40 /* Check parameters */
41 if (FileName == NULL)
42 {
44 goto cleanup;
45 }
46
48 if (len == 0)
49 goto cleanup;
50 FileNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
51 if (!FileNameW)
52 {
54 goto cleanup;
55 }
56 if (MultiByteToWideChar(CP_ACP, 0, FileName, -1, FileNameW, len) == 0)
57 goto cleanup;
58
59 ret = DeleteFileToRecycleBinW(FileNameW);
60
62 HeapFree(GetProcessHeap(), 0, FileNameW);
63 return ret;
64}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#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 void cleanup(void)
Definition: main.c:1335
BOOL WINAPI DeleteFileToRecycleBinW(IN LPCWSTR FileName)
Definition: recyclebin.c:67
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_a
Definition: kernel32.h:31
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ DeleteFileToRecycleBinW()

BOOL WINAPI DeleteFileToRecycleBinW ( IN LPCWSTR  FileName)

Definition at line 67 of file recyclebin.c.

69{
70 IRecycleBin *prb;
71 HRESULT hr;
72
73 TRACE("(%s)\n", debugstr_w(FileName));
74
76 if (!SUCCEEDED(hr))
77 goto cleanup;
78
79 hr = IRecycleBin_DeleteFile(prb, FileName);
80 IRecycleBin_Release(prb);
81
83 if (SUCCEEDED(hr))
84 return TRUE;
87 else
89 return FALSE;
90}
HRESULT WINAPI GetDefaultRecycleBin(IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
Definition: recyclebin.c:399
#define debugstr_w
Definition: kernel32.h:32

Referenced by DeleteFileToRecycleBinA().

◆ EmptyRecycleBinA()

BOOL WINAPI EmptyRecycleBinA ( IN LPCSTR pszRoot  OPTIONAL)

Definition at line 113 of file recyclebin.c.

115{
116 int len;
117 LPWSTR szRootW = NULL;
118 BOOL ret = FALSE;
119
120 TRACE("(%s)\n", debugstr_a(pszRoot));
121
122 if (pszRoot)
123 {
124 len = MultiByteToWideChar(CP_ACP, 0, pszRoot, -1, NULL, 0);
125 if (len == 0)
126 goto cleanup;
127 szRootW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
128 if (!szRootW)
129 {
131 goto cleanup;
132 }
133 if (MultiByteToWideChar(CP_ACP, 0, pszRoot, -1, szRootW, len) == 0)
134 goto cleanup;
135 }
136
137 ret = EmptyRecycleBinW(szRootW);
138
139cleanup:
140 HeapFree(GetProcessHeap(), 0, szRootW);
141 return ret;
142}
BOOL WINAPI EmptyRecycleBinW(IN LPCWSTR pszRoot OPTIONAL)
Definition: recyclebin.c:145

◆ EmptyRecycleBinW()

BOOL WINAPI EmptyRecycleBinW ( IN LPCWSTR pszRoot  OPTIONAL)

Definition at line 145 of file recyclebin.c.

147{
148 IRecycleBin *prb;
149 HRESULT hr;
150
151 TRACE("(%s)\n", debugstr_w(pszRoot));
152
153 hr = GetDefaultRecycleBin(pszRoot, &prb);
154 if (!SUCCEEDED(hr))
155 goto cleanup;
156
157 hr = IRecycleBin_EmptyRecycleBin(prb);
158 IRecycleBin_Release(prb);
159
160cleanup:
161 if (SUCCEEDED(hr))
162 return TRUE;
165 else
167 return FALSE;
168}

Referenced by EmptyRecycleBinA(), and SHEmptyRecycleBinW().

◆ EnumerateRecycleBinA()

BOOL WINAPI EnumerateRecycleBinA ( IN LPCSTR pszRoot  OPTIONAL,
IN PENUMERATE_RECYCLEBIN_CALLBACK  pFnCallback,
IN PVOID Context  OPTIONAL 
)

Definition at line 171 of file recyclebin.c.

175{
176 int len;
177 LPWSTR szRootW = NULL;
178 BOOL ret = FALSE;
179
180 TRACE("(%s, %p, %p)\n", debugstr_a(pszRoot), pFnCallback, Context);
181
182 if (pszRoot)
183 {
184 len = MultiByteToWideChar(CP_ACP, 0, pszRoot, -1, NULL, 0);
185 if (len == 0)
186 goto cleanup;
187 szRootW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
188 if (!szRootW)
189 {
191 goto cleanup;
192 }
193 if (MultiByteToWideChar(CP_ACP, 0, pszRoot, -1, szRootW, len) == 0)
194 goto cleanup;
195 }
196
197 ret = EnumerateRecycleBinW(szRootW, pFnCallback, Context);
198
199cleanup:
200 HeapFree(GetProcessHeap(), 0, szRootW);
201 return ret;
202}
BOOL WINAPI EnumerateRecycleBinW(IN LPCWSTR pszRoot OPTIONAL, IN PENUMERATE_RECYCLEBIN_CALLBACK pFnCallback, IN PVOID Context OPTIONAL)
Definition: recyclebin.c:205

◆ EnumerateRecycleBinW()

BOOL WINAPI EnumerateRecycleBinW ( IN LPCWSTR pszRoot  OPTIONAL,
IN PENUMERATE_RECYCLEBIN_CALLBACK  pFnCallback,
IN PVOID Context  OPTIONAL 
)

Definition at line 205 of file recyclebin.c.

209{
210 IRecycleBin *prb = NULL;
211 IRecycleBinEnumList *prbel = NULL;
212 IRecycleBinFile *prbf;
213 HRESULT hr;
214
215 TRACE("(%s, %p, %p)\n", debugstr_w(pszRoot), pFnCallback, Context);
216
218 if (!SUCCEEDED(hr))
219 goto cleanup;
220
221 hr = IRecycleBin_EnumObjects(prb, &prbel);
222 if (!SUCCEEDED(hr))
223 goto cleanup;
224 while (TRUE)
225 {
226 hr = IRecycleBinEnumList_Next(prbel, 1, &prbf, NULL);
227 if (hr == S_FALSE)
228 {
229 hr = S_OK;
230 goto cleanup;
231 }
232 else if (!SUCCEEDED(hr))
233 goto cleanup;
234 if (!pFnCallback(Context, (HANDLE)prbf))
235 {
237 goto cleanup;
238 }
239 }
240
241cleanup:
242 if (prb)
243 IRecycleBin_Release(prb);
244 if (prbel)
245 IRecycleBinEnumList_Release(prbel);
246 if (SUCCEEDED(hr))
247 return TRUE;
250 else
252 return FALSE;
253}
#define S_OK
Definition: intsafe.h:52
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define S_FALSE
Definition: winerror.h:2357
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by CRecyclerExtractIcon_CreateInstance(), EnumerateRecycleBinA(), CRecycleBin::GetDetailsOf(), CRecycleBinEnum::Initialize(), and CRecycleBinItemContextMenu::InvokeCommand().

◆ GetDefaultRecycleBin()

HRESULT WINAPI GetDefaultRecycleBin ( IN LPCWSTR pszVolume  OPTIONAL,
OUT IRecycleBin **  pprb 
)

Definition at line 399 of file recyclebin.c.

402{
403 IUnknown *pUnk;
404 HRESULT hr;
405
406 TRACE("(%s, %p)\n", debugstr_w(pszVolume), pprb);
407
408 if (!pprb)
409 return E_POINTER;
410
411 if (!pszVolume)
413 else
414 {
415 /* FIXME: do a better validation! */
416 if (wcslen(pszVolume) != 3 || pszVolume[1] != ':' || pszVolume[2] != '\\')
418
419 /* For now, only support this type of recycle bins... */
420 hr = RecycleBin5_Constructor(pszVolume, &pUnk);
421 }
422 if (!SUCCEEDED(hr))
423 return hr;
424 hr = IUnknown_QueryInterface(pUnk, &IID_IRecycleBin, (void **)pprb);
425 IUnknown_Release(pUnk);
426 return hr;
427}
#define ERROR_INVALID_NAME
Definition: compat.h:103
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
EXTERN_C const IID IID_IRecycleBin
Definition: recyclebin.h:246
HRESULT RecycleBinGeneric_Constructor(OUT IUnknown **ppUnknown)
HRESULT RecycleBin5_Constructor(IN LPCWSTR VolumePath, OUT IUnknown **ppUnknown)
#define E_POINTER
Definition: winerror.h:2365

Referenced by DeleteFileToRecycleBinW(), EmptyRecycleBinW(), EnumerateRecycleBinW(), RecycleBinGeneric_RecycleBin_DeleteFile(), RecycleBinGeneric_RecycleBin_EmptyRecycleBin(), RecycleBinGenericEnum_RecycleBinEnumList_Next(), and SHQueryRecycleBinW().

◆ GetDeletedFileDetailsA()

BOOL WINAPI GetDeletedFileDetailsA ( IN HDELFILE  hDeletedFile,
IN DWORD  BufferSize,
IN OUT PDELETED_FILE_DETAILS_A FileDetails  OPTIONAL,
OUT LPDWORD RequiredSize  OPTIONAL 
)

Definition at line 282 of file recyclebin.c.

287{
288 PDELETED_FILE_DETAILS_W FileDetailsW = NULL;
289 DWORD BufferSizeW = 0;
290 BOOL ret = FALSE;
291
292 TRACE("(%p, %lu, %p, %p)\n", hDeletedFile, BufferSize, FileDetails, RequiredSize);
293
295 {
298 }
299 if (FileDetails && BufferSizeW)
300 {
301 FileDetailsW = HeapAlloc(GetProcessHeap(), 0, BufferSizeW);
302 if (!FileDetailsW)
303 {
305 goto cleanup;
306 }
307 }
308
309 ret = GetDeletedFileDetailsW(hDeletedFile, BufferSizeW, FileDetailsW, RequiredSize);
310 if (!ret)
311 goto cleanup;
312
313 if (FileDetails)
314 {
315 CopyMemory(FileDetails, FileDetailsW, FIELD_OFFSET(DELETED_FILE_DETAILS_A, FileName));
316 if (0 == WideCharToMultiByte(CP_ACP, 0, FileDetailsW->FileName, -1, FileDetails->FileName, BufferSize - FIELD_OFFSET(DELETED_FILE_DETAILS_A, FileName), NULL, NULL))
317 goto cleanup;
318 }
319 ret = TRUE;
320
321cleanup:
322 HeapFree(GetProcessHeap(), 0, FileDetailsW);
323 return ret;
324}
#define WideCharToMultiByte
Definition: compat.h:111
BOOL WINAPI GetDeletedFileDetailsW(IN HDELFILE hDeletedFile, IN DWORD BufferSize, IN OUT PDELETED_FILE_DETAILS_W FileDetails OPTIONAL, OUT LPDWORD RequiredSize OPTIONAL)
Definition: recyclebin.c:327
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR FileName[ANY_SIZE]
Definition: recyclebin.h:40
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define CopyMemory
Definition: winbase.h:1710

◆ GetDeletedFileDetailsW()

BOOL WINAPI GetDeletedFileDetailsW ( IN HDELFILE  hDeletedFile,
IN DWORD  BufferSize,
IN OUT PDELETED_FILE_DETAILS_W FileDetails  OPTIONAL,
OUT LPDWORD RequiredSize  OPTIONAL 
)

Definition at line 327 of file recyclebin.c.

332{
333 IRecycleBinFile *rbf = (IRecycleBinFile *)hDeletedFile;
334 HRESULT hr;
335 SIZE_T NameSize, Needed;
336
337 TRACE("(%p, %lu, %p, %p)\n", hDeletedFile, BufferSize, FileDetails, RequiredSize);
338
339 hr = IRecycleBinFile_GetFileName(rbf, 0, NULL, &NameSize);
340 if (!SUCCEEDED(hr))
341 goto cleanup;
342 Needed = FIELD_OFFSET(DELETED_FILE_DETAILS_W, FileName) + NameSize;
343 if (RequiredSize)
344 *RequiredSize = (DWORD)Needed;
345 if (Needed > BufferSize)
346 {
348 goto cleanup;
349 }
350 hr = IRecycleBinFile_GetFileName(rbf, NameSize, FileDetails->FileName, NULL);
351 if (!SUCCEEDED(hr))
352 goto cleanup;
353 hr = IRecycleBinFile_GetLastModificationTime(rbf, &FileDetails->LastModification);
354 if (!SUCCEEDED(hr))
355 goto cleanup;
356 hr = IRecycleBinFile_GetDeletionTime(rbf, &FileDetails->DeletionTime);
357 if (!SUCCEEDED(hr))
358 goto cleanup;
359 hr = IRecycleBinFile_GetFileSize(rbf, &FileDetails->FileSize);
360 if (!SUCCEEDED(hr))
361 goto cleanup;
362 hr = IRecycleBinFile_GetPhysicalFileSize(rbf, &FileDetails->PhysicalFileSize);
363 if (!SUCCEEDED(hr))
364 goto cleanup;
365 hr = IRecycleBinFile_GetAttributes(rbf, &FileDetails->Attributes);
366 if (!SUCCEEDED(hr))
367 goto cleanup;
368
369cleanup:
370 if (SUCCEEDED(hr))
371 return TRUE;
374 else
376 return FALSE;
377}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define DWORD
Definition: nt_native.h:44
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by CRecycleBinEnum::CBEnumRecycleBin(), CBSearchRecycleBin(), and GetDeletedFileDetailsA().

◆ GetDeletedFileTypeNameW()

BOOL WINAPI GetDeletedFileTypeNameW ( IN HDELFILE  hDeletedFile,
OUT LPWSTR  pTypeName,
IN DWORD  BufferSize,
OUT LPDWORD RequiredSize  OPTIONAL 
)

Definition at line 256 of file recyclebin.c.

261{
262 IRecycleBinFile *prbf = (IRecycleBinFile *)hDeletedFile;
263 SIZE_T FinalSize;
264
265 HRESULT hr = IRecycleBinFile_GetTypeName(prbf, BufferSize, pTypeName, &FinalSize);
266
267 if (SUCCEEDED(hr))
268 {
269 if (RequiredSize)
270 *RequiredSize = (DWORD)FinalSize;
271
272 return TRUE;
273 }
276 else
278 return FALSE;
279}

Referenced by CRecycleBin::GetDetailsOf().

◆ RestoreFile()

BOOL WINAPI RestoreFile ( IN HDELFILE  hDeletedFile)

Definition at line 380 of file recyclebin.c.

382{
383 IRecycleBinFile *rbf = (IRecycleBinFile *)hDeletedFile;
384 HRESULT hr;
385
386 TRACE("(%p)\n", hDeletedFile);
387
388 hr = IRecycleBinFile_Restore(rbf);
389 if (SUCCEEDED(hr))
390 return TRUE;
393 else
395 return FALSE;
396}

Referenced by CRecycleBinItemContextMenu::InvokeCommand().