ReactOS 0.4.16-dev-117-g38f21f9
RecycleBinGeneric Class Reference
Inheritance diagram for RecycleBinGeneric:
Collaboration diagram for RecycleBinGeneric:

Public Member Functions

 RecycleBinGeneric ()
 
virtual ~RecycleBinGeneric ()
 
STDMETHODIMP QueryInterface (REFIID riid, void **ppvObject) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP DeleteFile (LPCWSTR szFileName) override
 
STDMETHODIMP EmptyRecycleBin () override
 
STDMETHODIMP EnumObjects (IRecycleBinEnumList **ppEnumList) override
 

Protected Attributes

LONG m_ref
 

Detailed Description

Definition at line 11 of file recyclebin_generic.cpp.

Constructor & Destructor Documentation

◆ RecycleBinGeneric()

RecycleBinGeneric::RecycleBinGeneric ( )

Definition at line 169 of file recyclebin_generic.cpp.

170 : m_ref(1)
171{
172}

◆ ~RecycleBinGeneric()

RecycleBinGeneric::~RecycleBinGeneric ( )
virtual

Definition at line 57 of file recyclebin_generic.cpp.

58{
59 TRACE("(%p)\n", this);
60}
#define TRACE(s)
Definition: solgame.cpp:4

Member Function Documentation

◆ DeleteFile()

STDMETHODIMP RecycleBinGeneric::DeleteFile ( LPCWSTR  szFileName)
override

Definition at line 72 of file recyclebin_generic.cpp.

73{
74 TRACE("(%p, %s)\n", this, debugstr_w(szFileName));
75
76 /* Get full file name */
77 LPWSTR szFullName = NULL;
78 DWORD dwBufferLength = 0;
79 while (TRUE)
80 {
81 DWORD len = GetFullPathNameW(szFileName, dwBufferLength, szFullName, NULL);
82 if (len == 0)
83 {
84 if (szFullName)
85 CoTaskMemFree(szFullName);
87 }
88 else if (len < dwBufferLength)
89 break;
90 if (szFullName)
91 CoTaskMemFree(szFullName);
92 dwBufferLength = len;
93 szFullName = (LPWSTR)CoTaskMemAlloc(dwBufferLength * sizeof(WCHAR));
94 if (!szFullName)
96 }
97
98 /* Get associated volume path */
99 WCHAR szVolume[MAX_PATH];
100#ifndef __REACTOS__
101 if (!GetVolumePathNameW(szFullName, szVolume, _countof(szVolume)))
102 {
103 CoTaskMemFree(szFullName);
105 }
106#else
107 swprintf(szVolume, L"%c:\\", szFullName[0]);
108#endif
109
110 /* Skip namespace (if any): "\\.\" or "\\?\" */
111 if (szVolume[0] == '\\' &&
112 szVolume[1] == '\\' &&
113 (szVolume[2] == '.' || szVolume[2] == '?') &&
114 szVolume[3] == '\\')
115 {
116 MoveMemory(szVolume, &szVolume[4], (_countof(szVolume) - 4) * sizeof(WCHAR));
117 }
118
119 IRecycleBin *prb;
120 HRESULT hr = GetDefaultRecycleBin(szVolume, &prb);
121 if (!SUCCEEDED(hr))
122 {
123 CoTaskMemFree(szFullName);
124 return hr;
125 }
126
127 hr = prb->DeleteFile(szFullName);
128 CoTaskMemFree(szFullName);
129 prb->Release();
130 return hr;
131}
#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
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#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
#define _countof(array)
Definition: sndvol32.h:70
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

◆ EmptyRecycleBin()

STDMETHODIMP RecycleBinGeneric::EmptyRecycleBin ( )
override

Definition at line 133 of file recyclebin_generic.cpp.

134{
135 TRACE("(%p)\n", this);
136
137 DWORD dwLogicalDrives = GetLogicalDrives();
138 if (dwLogicalDrives == 0)
140
141 for (DWORD i = 0; i < 'Z' - 'A' + 1; i++)
142 {
143 if (!(dwLogicalDrives & (1 << i)))
144 continue;
145
146 WCHAR szVolumeName[MAX_PATH];
147 swprintf(szVolumeName, L"%c:\\", L'A' + i);
148 if (GetDriveTypeW(szVolumeName) != DRIVE_FIXED)
149 continue;
150
151 IRecycleBin *prb;
152 HRESULT hr = GetDefaultRecycleBin(szVolumeName, &prb);
153 if (!SUCCEEDED(hr))
154 return hr;
155
156 hr = prb->EmptyRecycleBin();
157 prb->Release();
158 }
159
160 return S_OK;
161}
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
ULONG Release()
#define S_OK
Definition: intsafe.h:52
DWORD WINAPI GetLogicalDrives(void)
Definition: disk.c:110
#define DRIVE_FIXED
Definition: winbase.h:252

◆ EnumObjects()

STDMETHODIMP RecycleBinGeneric::EnumObjects ( IRecycleBinEnumList **  ppEnumList)
override

Definition at line 163 of file recyclebin_generic.cpp.

164{
165 TRACE("(%p, %p)\n", this, ppEnumList);
166 return RecycleBinGenericEnum_Constructor(ppEnumList);
167}
EXTERN_C HRESULT RecycleBinGenericEnum_Constructor(OUT IRecycleBinEnumList **pprbel)

◆ QueryInterface()

STDMETHODIMP RecycleBinGeneric::QueryInterface ( REFIID  riid,
void **  ppvObject 
)
override

Definition at line 31 of file recyclebin_generic.cpp.

32{
33 TRACE("(%p, %s, %p)\n", this, debugstr_guid(&riid), ppvObject);
34
35 if (!ppvObject)
36 return E_POINTER;
37
39 *ppvObject = static_cast<IRecycleBin *>(this);
40 else
41 {
42 *ppvObject = NULL;
43 return E_NOINTERFACE;
44 }
45
46 AddRef();
47 return S_OK;
48}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
EXTERN_C const IID IID_IRecycleBin
Definition: recyclebin.h:246
_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

◆ STDMETHODIMP_() [1/2]

RecycleBinGeneric::STDMETHODIMP_ ( ULONG  )
override

◆ STDMETHODIMP_() [2/2]

RecycleBinGeneric::STDMETHODIMP_ ( ULONG  )
override

Member Data Documentation

◆ m_ref

LONG RecycleBinGeneric::m_ref
protected

Definition at line 28 of file recyclebin_generic.cpp.

Referenced by STDMETHODIMP_().


The documentation for this class was generated from the following file: