ReactOS 0.4.15-dev-7681-g776c3a3
recyclebin_generic.c File Reference
Include dependency graph for recyclebin_generic.c:

Go to the source code of this file.

Classes

struct  RecycleBinGeneric
 

Functions

static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_QueryInterface (IRecycleBin *This, REFIID riid, void **ppvObject)
 
static ULONG STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_AddRef (IRecycleBin *This)
 
static VOID RecycleBinGeneric_Destructor (struct RecycleBinGeneric *s)
 
static ULONG STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_Release (IRecycleBin *This)
 
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_DeleteFile (IN IRecycleBin *This, IN LPCWSTR szFileName)
 
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_EmptyRecycleBin (IN IRecycleBin *This)
 
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_EnumObjects (IN IRecycleBin *This, OUT IRecycleBinEnumList **ppEnumList)
 
HRESULT RecycleBinGeneric_Constructor (OUT IUnknown **ppUnknown)
 

Variables

CONST_VTBL struct IRecycleBinVtbl RecycleBinGenericVtbl
 

Function Documentation

◆ RecycleBinGeneric_Constructor()

HRESULT RecycleBinGeneric_Constructor ( OUT IUnknown **  ppUnknown)

Definition at line 200 of file recyclebin_generic.c.

201{
202 /* This RecycleBin implementation was introduced to be able to manage all
203 * drives at once, and instanciate the 'real' implementations when needed */
204 struct RecycleBinGeneric *s;
205
206 s = CoTaskMemAlloc(sizeof(struct RecycleBinGeneric));
207 if (!s)
208 return E_OUTOFMEMORY;
209 s->ref = 1;
210 s->recycleBinImpl.lpVtbl = &RecycleBinGenericVtbl;
211
212 *ppUnknown = (IUnknown *)&s->recycleBinImpl;
213 return S_OK;
214}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLdouble s
Definition: gl.h:2039
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
CONST_VTBL struct IRecycleBinVtbl RecycleBinGenericVtbl

Referenced by GetDefaultRecycleBin().

◆ RecycleBinGeneric_Destructor()

static VOID RecycleBinGeneric_Destructor ( struct RecycleBinGeneric s)
static

Definition at line 55 of file recyclebin_generic.c.

57{
58 TRACE("(%p)\n", s);
59
61}
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by RecycleBinGeneric_RecycleBin_Release().

◆ RecycleBinGeneric_RecycleBin_AddRef()

static ULONG STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_AddRef ( IRecycleBin *  This)
static

Definition at line 45 of file recyclebin_generic.c.

47{
49 ULONG refCount = InterlockedIncrement((PLONG)&s->ref);
50 TRACE("(%p)\n", This);
51 return refCount;
52}
#define InterlockedIncrement
Definition: armddk.h:53
IRecycleBin recycleBinImpl
int32_t * PLONG
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59

◆ RecycleBinGeneric_RecycleBin_DeleteFile()

static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_DeleteFile ( IN IRecycleBin *  This,
IN LPCWSTR  szFileName 
)
static

Definition at line 81 of file recyclebin_generic.c.

84{
85 IRecycleBin *prb;
86 LPWSTR szFullName = NULL;
87 DWORD dwBufferLength = 0;
88 DWORD len;
89 WCHAR szVolume[MAX_PATH];
90 HRESULT hr;
91
92 TRACE("(%p, %s)\n", This, debugstr_w(szFileName));
93
94 /* Get full file name */
95 while (TRUE)
96 {
97 len = GetFullPathNameW(szFileName, dwBufferLength, szFullName, NULL);
98 if (len == 0)
99 {
100 if (szFullName)
101 CoTaskMemFree(szFullName);
103 }
104 else if (len < dwBufferLength)
105 break;
106 if (szFullName)
107 CoTaskMemFree(szFullName);
108 dwBufferLength = len;
109 szFullName = CoTaskMemAlloc(dwBufferLength * sizeof(WCHAR));
110 if (!szFullName)
112 }
113
114 /* Get associated volume path */
115#ifndef __REACTOS__
116 if (!GetVolumePathNameW(szFullName, szVolume, MAX_PATH))
117 {
118 CoTaskMemFree(szFullName);
120 }
121#else
122 swprintf(szVolume, L"%c:\\", szFullName[0]);
123#endif
124
125 /* Skip namespace (if any) */
126 if (szVolume[0] == '\\'
127 && szVolume[1] == '\\'
128 && (szVolume[2] == '.' || szVolume[2] == '?')
129 && szVolume[3] == '\\')
130 {
131 MoveMemory(szVolume, &szVolume[4], (MAX_PATH - 4) * sizeof(WCHAR));
132 }
133
134 hr = GetDefaultRecycleBin(szVolume, &prb);
135 if (!SUCCEEDED(hr))
136 {
137 CoTaskMemFree(szFullName);
138 return hr;
139 }
140
141 hr = IRecycleBin_DeleteFile(prb, szFullName);
142 CoTaskMemFree(szFullName);
143 IRecycleBin_Release(prb);
144 return hr;
145}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI GetVolumePathNameW(IN LPCWSTR lpszFileName, IN LPWSTR lpszVolumePathName, IN DWORD cchBufferLength)
Definition: volume.c:815
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
HRESULT WINAPI GetDefaultRecycleBin(IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
Definition: recyclebin.c:399
#define swprintf
Definition: precomp.h:40
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
#define L(x)
Definition: ntvdm.h:50
HRESULT hr
Definition: shlfolder.c:183
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MoveMemory
Definition: winbase.h:1709
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ RecycleBinGeneric_RecycleBin_EmptyRecycleBin()

static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_EmptyRecycleBin ( IN IRecycleBin *  This)
static

Definition at line 148 of file recyclebin_generic.c.

150{
151 WCHAR szVolumeName[MAX_PATH];
152 DWORD dwLogicalDrives, i;
153 IRecycleBin *prb;
154 HRESULT hr;
155
156 TRACE("(%p)\n", This);
157
158 dwLogicalDrives = GetLogicalDrives();
159 if (dwLogicalDrives == 0)
161
162 for (i = 0; i < 26; i++)
163 {
164 if (!(dwLogicalDrives & (1 << i)))
165 continue;
166 swprintf(szVolumeName, L"%c:\\", 'A' + i);
167 if (GetDriveTypeW(szVolumeName) != DRIVE_FIXED)
168 continue;
169
170 hr = GetDefaultRecycleBin(szVolumeName, &prb);
171 if (!SUCCEEDED(hr))
172 return hr;
173
174 hr = IRecycleBin_EmptyRecycleBin(prb);
175 IRecycleBin_Release(prb);
176 }
177
178 return S_OK;
179}
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD WINAPI GetLogicalDrives(void)
Definition: disk.c:110
#define DRIVE_FIXED
Definition: winbase.h:252

◆ RecycleBinGeneric_RecycleBin_EnumObjects()

static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_EnumObjects ( IN IRecycleBin *  This,
OUT IRecycleBinEnumList **  ppEnumList 
)
static

Definition at line 182 of file recyclebin_generic.c.

185{
186 TRACE("(%p, %p)\n", This, ppEnumList);
187 return RecycleBinGenericEnum_Constructor(ppEnumList);
188}
HRESULT RecycleBinGenericEnum_Constructor(OUT IRecycleBinEnumList **pprbel)

◆ RecycleBinGeneric_RecycleBin_QueryInterface()

static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_QueryInterface ( IRecycleBin *  This,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 18 of file recyclebin_generic.c.

22{
24
25 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
26
27 if (!ppvObject)
28 return E_POINTER;
29
31 *ppvObject = &s->recycleBinImpl;
33 *ppvObject = &s->recycleBinImpl;
34 else
35 {
36 *ppvObject = NULL;
37 return E_NOINTERFACE;
38 }
39
40 IUnknown_AddRef(This);
41 return S_OK;
42}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
EXTERN_C const IID IID_IRecycleBin
Definition: recyclebin.h:243
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365

◆ RecycleBinGeneric_RecycleBin_Release()

static ULONG STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_Release ( IRecycleBin *  This)
static

Definition at line 64 of file recyclebin_generic.c.

66{
68 ULONG refCount;
69
70 TRACE("(%p)\n", This);
71
72 refCount = InterlockedDecrement((PLONG)&s->ref);
73
74 if (refCount == 0)
76
77 return refCount;
78}
#define InterlockedDecrement
Definition: armddk.h:52
static VOID RecycleBinGeneric_Destructor(struct RecycleBinGeneric *s)

Variable Documentation

◆ RecycleBinGenericVtbl

CONST_VTBL struct IRecycleBinVtbl RecycleBinGenericVtbl
Initial value:
=
{
}
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_EnumObjects(IN IRecycleBin *This, OUT IRecycleBinEnumList **ppEnumList)
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_EmptyRecycleBin(IN IRecycleBin *This)
static ULONG STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_AddRef(IRecycleBin *This)
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_DeleteFile(IN IRecycleBin *This, IN LPCWSTR szFileName)
static HRESULT STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_QueryInterface(IRecycleBin *This, REFIID riid, void **ppvObject)
static ULONG STDMETHODCALLTYPE RecycleBinGeneric_RecycleBin_Release(IRecycleBin *This)

Definition at line 190 of file recyclebin_generic.c.

Referenced by RecycleBinGeneric_Constructor().