ReactOS 0.4.15-dev-7924-g5949c20
recyclebin_generic_enumerator.c File Reference
Include dependency graph for recyclebin_generic_enumerator.c:

Go to the source code of this file.

Classes

struct  RecycleBinGenericEnum
 

Functions

static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_QueryInterface (IN IRecycleBinEnumList *This, IN REFIID riid, OUT void **ppvObject)
 
static ULONG STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_AddRef (IN IRecycleBinEnumList *This)
 
static VOID RecycleBinGenericEnum_Destructor (struct RecycleBinGenericEnum *s)
 
static ULONG STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Release (IN IRecycleBinEnumList *This)
 
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Next (IN IRecycleBinEnumList *This, IN DWORD celt, IN OUT IRecycleBinFile **rgelt, OUT DWORD *pceltFetched)
 
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Skip (IN IRecycleBinEnumList *This, IN DWORD celt)
 
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Reset (IN IRecycleBinEnumList *This)
 
HRESULT RecycleBinGenericEnum_Constructor (OUT IRecycleBinEnumList **pprbel)
 

Variables

CONST_VTBL struct IRecycleBinEnumListVtbl RecycleBinGenericEnumVtbl
 

Function Documentation

◆ RecycleBinGenericEnum_Constructor()

HRESULT RecycleBinGenericEnum_Constructor ( OUT IRecycleBinEnumList **  pprbel)

Definition at line 219 of file recyclebin_generic_enumerator.c.

221{
222 struct RecycleBinGenericEnum *s;
223
224 s = CoTaskMemAlloc(sizeof(struct RecycleBinGenericEnum));
225 if (!s)
226 return E_OUTOFMEMORY;
227 ZeroMemory(s, sizeof(struct RecycleBinGenericEnum));
228 s->ref = 1;
229 s->recycleBinEnumImpl.lpVtbl = &RecycleBinGenericEnumVtbl;
230
231 *pprbel = &s->recycleBinEnumImpl;
232 return IRecycleBinEnumList_Reset(*pprbel);
233}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLdouble s
Definition: gl.h:2039
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
CONST_VTBL struct IRecycleBinEnumListVtbl RecycleBinGenericEnumVtbl
#define ZeroMemory
Definition: winbase.h:1712

Referenced by RecycleBinGeneric_RecycleBin_EnumObjects().

◆ RecycleBinGenericEnum_Destructor()

static VOID RecycleBinGenericEnum_Destructor ( struct RecycleBinGenericEnum s)
static

Definition at line 58 of file recyclebin_generic_enumerator.c.

60{
61 TRACE("(%p)\n", s);
62
63 if (s->current)
64 IRecycleBinEnumList_Release(s->current);
66}
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by RecycleBinGenericEnum_RecycleBinEnumList_Release().

◆ RecycleBinGenericEnum_RecycleBinEnumList_AddRef()

static ULONG STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_AddRef ( IN IRecycleBinEnumList *  This)
static

Definition at line 48 of file recyclebin_generic_enumerator.c.

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

◆ RecycleBinGenericEnum_RecycleBinEnumList_Next()

static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Next ( IN IRecycleBinEnumList *  This,
IN DWORD  celt,
IN OUT IRecycleBinFile **  rgelt,
OUT DWORD pceltFetched 
)
static

Definition at line 86 of file recyclebin_generic_enumerator.c.

91{
93 IRecycleBin *prb;
94 DWORD i;
95 DWORD fetched = 0, newFetched;
96 HRESULT hr;
97
98 TRACE("(%p, %u, %p, %p)\n", This, celt, rgelt, pceltFetched);
99
100 if (!rgelt)
101 return E_POINTER;
102 if (!pceltFetched && celt > 1)
103 return E_INVALIDARG;
104
105 while (TRUE)
106 {
107 /* Get enumerator implementation */
108 if (!s->current && s->dwLogicalDrives)
109 {
110 for (i = 0; i < 26; i++)
111 if (s->dwLogicalDrives & (1 << i))
112 {
113 WCHAR szVolumeName[4];
114 szVolumeName[0] = (WCHAR)('A' + i);
115 szVolumeName[1] = ':';
116 szVolumeName[2] = '\\';
117 szVolumeName[3] = UNICODE_NULL;
118 if (GetDriveTypeW(szVolumeName) != DRIVE_FIXED)
119 {
120 s->dwLogicalDrives &= ~(1 << i);
121 continue;
122 }
123 hr = GetDefaultRecycleBin(szVolumeName, &prb);
124 if (!SUCCEEDED(hr))
125 return hr;
126 hr = IRecycleBin_EnumObjects(prb, &s->current);
127 IRecycleBin_Release(prb);
128 if (!SUCCEEDED(hr))
129 return hr;
130 s->dwLogicalDrives &= ~(1 << i);
131 break;
132 }
133 }
134 if (!s->current)
135 {
136 /* Nothing more to enumerate */
137 if (pceltFetched)
138 *pceltFetched = fetched;
139 return S_FALSE;
140 }
141
142 /* Skip some elements */
143 while (s->skip > 0)
144 {
145 IRecycleBinFile *rbf;
146 hr = IRecycleBinEnumList_Next(s->current, 1, &rbf, NULL);
147 if (hr == S_OK)
148 hr = IRecycleBinFile_Release(rbf);
149 else if (hr == S_FALSE)
150 break;
151 else if (!SUCCEEDED(hr))
152 return hr;
153 }
154 if (s->skip > 0)
155 continue;
156
157 /* Fill area */
158 hr = IRecycleBinEnumList_Next(s->current, celt - fetched, &rgelt[fetched], &newFetched);
159 if (SUCCEEDED(hr))
160 fetched += newFetched;
161 if (hr == S_FALSE || newFetched == 0)
162 {
163 hr = IRecycleBinEnumList_Release(s->current);
164 s->current = NULL;
165 }
166 else if (!SUCCEEDED(hr))
167 return hr;
168 if (fetched == celt)
169 {
170 if (pceltFetched)
171 *pceltFetched = fetched;
172 return S_OK;
173 }
174 }
175
176 /* Never go here */
177}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
HRESULT WINAPI GetDefaultRecycleBin(IN LPCWSTR pszVolume OPTIONAL, OUT IRecycleBin **pprb)
Definition: recyclebin.c:399
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define UNICODE_NULL
HRESULT hr
Definition: shlfolder.c:183
#define DRIVE_FIXED
Definition: winbase.h:252
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ RecycleBinGenericEnum_RecycleBinEnumList_QueryInterface()

static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_QueryInterface ( IN IRecycleBinEnumList *  This,
IN REFIID  riid,
OUT void **  ppvObject 
)
static

Definition at line 21 of file recyclebin_generic_enumerator.c.

25{
27
28 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
29
30 if (!ppvObject)
31 return E_POINTER;
32
34 *ppvObject = &s->recycleBinEnumImpl;
36 *ppvObject = &s->recycleBinEnumImpl;
37 else
38 {
39 *ppvObject = NULL;
40 return E_NOINTERFACE;
41 }
42
43 IUnknown_AddRef(This);
44 return S_OK;
45}
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_IRecycleBinEnumList
Definition: recyclebin.h:242
_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

◆ RecycleBinGenericEnum_RecycleBinEnumList_Release()

static ULONG STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Release ( IN IRecycleBinEnumList *  This)
static

Definition at line 69 of file recyclebin_generic_enumerator.c.

71{
73 ULONG refCount;
74
75 TRACE("(%p)\n", This);
76
77 refCount = InterlockedDecrement((PLONG)&s->ref);
78
79 if (refCount == 0)
81
82 return refCount;
83}
#define InterlockedDecrement
Definition: armddk.h:52
static VOID RecycleBinGenericEnum_Destructor(struct RecycleBinGenericEnum *s)

◆ RecycleBinGenericEnum_RecycleBinEnumList_Reset()

static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Reset ( IN IRecycleBinEnumList *  This)
static

Definition at line 191 of file recyclebin_generic_enumerator.c.

193{
195
196 TRACE("(%p)\n", This);
197
198 if (s->current)
199 {
200 IRecycleBinEnumList_Release(s->current);
201 s->current = NULL;
202 s->skip = 0;
203 }
204 s->dwLogicalDrives = GetLogicalDrives();
205 return S_OK;
206}
DWORD WINAPI GetLogicalDrives(void)
Definition: disk.c:110

◆ RecycleBinGenericEnum_RecycleBinEnumList_Skip()

static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Skip ( IN IRecycleBinEnumList *  This,
IN DWORD  celt 
)
static

Definition at line 180 of file recyclebin_generic_enumerator.c.

183{
185 TRACE("(%p, %u)\n", This, celt);
186 s->skip += celt;
187 return S_OK;
188}

Variable Documentation

◆ RecycleBinGenericEnumVtbl

CONST_VTBL struct IRecycleBinEnumListVtbl RecycleBinGenericEnumVtbl
Initial value:
=
{
}
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_QueryInterface(IN IRecycleBinEnumList *This, IN REFIID riid, OUT void **ppvObject)
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Reset(IN IRecycleBinEnumList *This)
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Skip(IN IRecycleBinEnumList *This, IN DWORD celt)
static ULONG STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Release(IN IRecycleBinEnumList *This)
static ULONG STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_AddRef(IN IRecycleBinEnumList *This)
static HRESULT STDMETHODCALLTYPE RecycleBinGenericEnum_RecycleBinEnumList_Next(IN IRecycleBinEnumList *This, IN DWORD celt, IN OUT IRecycleBinFile **rgelt, OUT DWORD *pceltFetched)

Definition at line 208 of file recyclebin_generic_enumerator.c.

Referenced by RecycleBinGenericEnum_Constructor().