ReactOS  0.4.15-dev-1374-g8d3e80e
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
CONST_VTBL struct IRecycleBinVtbl RecycleBinGenericVtbl
GLdouble s
Definition: gl.h:2039
#define S_OK
Definition: intsafe.h:51
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

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
GLdouble s
Definition: gl.h:2039

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 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
GLdouble s
Definition: gl.h:2039
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5
IRecycleBin recycleBinImpl

◆ 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 HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
HRESULT WINAPI GetDefaultRecycleBin(IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
Definition: recyclebin.c:385
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
BOOL WINAPI GetVolumePathNameW(IN LPCWSTR lpszFileName, IN LPWSTR lpszVolumePathName, IN DWORD cchBufferLength)
Definition: volume.c:815
#define MoveMemory
Definition: winbase.h:1645
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

◆ 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 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI GetDefaultRecycleBin(IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
Definition: recyclebin.c:385
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
if SUCCEEDED(hr)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_FIXED
Definition: winbase.h:249
DWORD WINAPI GetLogicalDrives(VOID)
Definition: disk.c:110
#define S_OK
Definition: intsafe.h:51
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

◆ 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)
#define TRACE(s)
Definition: solgame.cpp:4

◆ 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;
32  else if (IsEqualIID(riid, &IID_IRecycleBin))
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 }
EXTERN_C const IID IID_IRecycleBin
Definition: recyclebin.h:249
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
GLdouble s
Definition: gl.h:2039
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define E_POINTER
Definition: winerror.h:2365
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
IRecycleBin recycleBinImpl

◆ 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 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
static VOID RecycleBinGeneric_Destructor(struct RecycleBinGeneric *s)
#define InterlockedDecrement
Definition: armddk.h:52
GLdouble s
Definition: gl.h:2039
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5
IRecycleBin recycleBinImpl

Variable Documentation

◆ RecycleBinGenericVtbl

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

Definition at line 190 of file recyclebin_generic.c.

Referenced by RecycleBinGeneric_Constructor().