ReactOS 0.4.16-dev-816-g135a9a9
RecycleBin5 Class Reference
Inheritance diagram for RecycleBin5:
Collaboration diagram for RecycleBin5:

Public Member Functions

 RecycleBin5 ()
 
virtual ~RecycleBin5 ()
 
HRESULT Init (_In_ LPCWSTR VolumePath)
 
STDMETHODIMP QueryInterface (_In_ REFIID riid, _Out_ void **ppvObject) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP DeleteFile (_In_ LPCWSTR szFileName) override
 
STDMETHODIMP EmptyRecycleBin () override
 
STDMETHODIMP EnumObjects (_Out_ IRecycleBinEnumList **ppEnumList) override
 
STDMETHODIMP GetDirectory (LPWSTR szPath) override
 
STDMETHODIMP Delete (_In_ LPCWSTR pDeletedFileName, _In_ DELETED_FILE_RECORD *pDeletedFile) override
 
STDMETHODIMP Restore (_In_ LPCWSTR pDeletedFileName, _In_ DELETED_FILE_RECORD *pDeletedFile) override
 
STDMETHODIMP RemoveFromDatabase (_In_ LPCWSTR pDeletedFileName, _In_ DELETED_FILE_RECORD *pDeletedFile) override
 
STDMETHODIMP OnClosing (_In_ IRecycleBinEnumList *prbel) override
 

Protected Attributes

LONG m_ref
 
HANDLE m_hInfo
 
HANDLE m_hInfoMapped
 
DWORD m_EnumeratorCount
 
CStringW m_VolumePath
 
CStringW m_Folder
 

Detailed Description

Definition at line 129 of file recyclebin_v5.cpp.

Constructor & Destructor Documentation

◆ RecycleBin5()

RecycleBin5::RecycleBin5 ( )

Definition at line 666 of file recyclebin_v5.cpp.

667 : m_ref(1)
668 , m_hInfo(NULL)
671{
672}
HANDLE m_hInfoMapped
DWORD m_EnumeratorCount
#define NULL
Definition: types.h:112

◆ ~RecycleBin5()

RecycleBin5::~RecycleBin5 ( )
virtual

Definition at line 202 of file recyclebin_v5.cpp.

203{
204 TRACE("(%p)\n", this);
205
208 if (m_hInfoMapped)
210}
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define TRACE(s)
Definition: solgame.cpp:4

Member Function Documentation

◆ Delete()

STDMETHODIMP RecycleBin5::Delete ( _In_ LPCWSTR  pDeletedFileName,
_In_ DELETED_FILE_RECORD pDeletedFile 
)
override

Definition at line 456 of file recyclebin_v5.cpp.

459{
460
461 TRACE("(%p, %s, %p)\n", this, debugstr_w(pDeletedFileName), pDeletedFile);
462
463 int res = IntDeleteRecursive(pDeletedFileName);
464 if (!res)
466 res = RemoveFromDatabase(pDeletedFileName, pDeletedFile);
467 if (res == 0)
468 SHUpdateRecycleBinIcon(); // Full --> Empty
469 return res;
470}
STDMETHODIMP RemoveFromDatabase(_In_ LPCWSTR pDeletedFileName, _In_ DELETED_FILE_RECORD *pDeletedFile) override
GLuint res
Definition: glext.h:9613
#define debugstr_w
Definition: kernel32.h:32
#define HResultFromWin32
Definition: loader.cpp:14
EXTERN_C HRESULT WINAPI SHUpdateRecycleBinIcon(void)
static BOOL IntDeleteRecursive(IN LPCWSTR FullName)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ DeleteFile()

STDMETHODIMP RecycleBin5::DeleteFile ( _In_ LPCWSTR  szFileName)
override

Definition at line 222 of file recyclebin_v5.cpp.

223{
224 LPWSTR szFullName = NULL;
225 DWORD dwBufferLength = 0;
228 CStringW DeletedFileName;
229 WCHAR szUniqueId[64];
230 DWORD len;
233 PDELETED_FILE_RECORD pDeletedFile;
235 DWORD dwAttributes, dwEntries;
236 SYSTEMTIME SystemTime;
237 DWORD ClusterSize, BytesPerSector, SectorsPerCluster;
238 HRESULT hr;
239 WIN32_FIND_DATAW wfd = {};
240
241 TRACE("(%p, %s)\n", this, debugstr_w(szFileName));
242
243 if (m_EnumeratorCount != 0)
245
246 /* Get full file name */
247 while (TRUE)
248 {
249 len = GetFullPathNameW(szFileName, dwBufferLength, szFullName, &lpFilePart);
250 if (len == 0)
251 {
252 if (szFullName)
253 CoTaskMemFree(szFullName);
255 }
256 else if (len < dwBufferLength)
257 break;
258 if (szFullName)
259 CoTaskMemFree(szFullName);
260 dwBufferLength = len;
261 szFullName = (LPWSTR)CoTaskMemAlloc(dwBufferLength * sizeof(WCHAR));
262 if (!szFullName)
264 }
265
266 /* Check if file exists */
267 dwAttributes = GetFileAttributesW(szFullName);
269 {
270 CoTaskMemFree(szFullName);
272 }
273
274 if (dwBufferLength < 2 || szFullName[1] != ':')
275 {
276 /* Not a local file */
277 CoTaskMemFree(szFullName);
279 }
280
283 {
285 goto cleanup;
286 }
287
288 /* Increase INFO2 file size */
293 if (!m_hInfoMapped)
294 {
296 goto cleanup;
297 }
298
299 /* Open INFO2 file */
301 if (!pHeader)
302 {
304 goto cleanup;
305 }
306
307 /* Get number of entries */
308 FileSize.u.LowPart = GetFileSize(m_hInfo, &FileSize.u.HighPart);
309 if (FileSize.u.LowPart < sizeof(INFO2_HEADER))
310 {
312 goto cleanup;
313 }
314 dwEntries = (DWORD)((FileSize.QuadPart - sizeof(INFO2_HEADER)) / sizeof(DELETED_FILE_RECORD)) - 1;
315 pDeletedFile = ((PDELETED_FILE_RECORD)(pHeader + 1)) + dwEntries;
316
317 /* Get file size */
318#if 0
320 {
322 goto cleanup;
323 }
324#else
325 FileSize.u.LowPart = GetFileSize(hFile, &FileSize.u.HighPart);
326 if (FileSize.u.LowPart == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)
327 {
329 goto cleanup;
330 }
331#endif
332 /* Check if file size is > 4Gb */
333 if (FileSize.u.HighPart != 0)
334 {
335 /* Yes, this recyclebin can't support this file */
337 goto cleanup;
338 }
339 pHeader->dwTotalLogicalSize += FileSize.u.LowPart;
340
341 /* Generate new name */
342 Extension = PathFindExtensionW(szFullName);
343 ZeroMemory(pDeletedFile, sizeof(DELETED_FILE_RECORD));
344 if (dwEntries == 0)
345 pDeletedFile->dwRecordUniqueId = 0;
346 else
347 {
348 PDELETED_FILE_RECORD pLastDeleted = ((PDELETED_FILE_RECORD)(pHeader + 1)) + dwEntries - 1;
349 pDeletedFile->dwRecordUniqueId = pLastDeleted->dwRecordUniqueId + 1;
350 }
351
352 pDeletedFile->dwDriveNumber = tolower(szFullName[0]) - 'a';
353 _ultow(pDeletedFile->dwRecordUniqueId, szUniqueId, 10);
354
355 DeletedFileName = m_Folder;
356 DeletedFileName += L"\\D";
357 DeletedFileName += (WCHAR)(L'a' + pDeletedFile->dwDriveNumber);
358 DeletedFileName += szUniqueId;
359 DeletedFileName += Extension;
360
361 /* Get cluster size */
362 if (!GetDiskFreeSpaceW(m_VolumePath, &SectorsPerCluster, &BytesPerSector, NULL, NULL))
363 {
365 goto cleanup;
366 }
367 ClusterSize = BytesPerSector * SectorsPerCluster;
368
369 /* Get current time */
370 GetSystemTime(&SystemTime);
371 if (!SystemTimeToFileTime(&SystemTime, &pDeletedFile->DeletionTime))
372 {
374 goto cleanup;
375 }
376 pDeletedFile->dwPhysicalFileSize = ROUND_UP(FileSize.u.LowPart, ClusterSize);
377
378 /* Set name */
379 wcscpy(pDeletedFile->FileNameW, szFullName);
380 if (WideCharToMultiByte(CP_ACP, 0, pDeletedFile->FileNameW, -1, pDeletedFile->FileNameA, MAX_PATH, NULL, NULL) == 0)
381 {
384 goto cleanup;
385 }
386
387 wfd.dwFileAttributes = dwAttributes;
388 wfd.nFileSizeLow = FileSize.u.LowPart;
389 GetFileTime(hFile, &wfd.ftCreationTime, &wfd.ftLastAccessTime, &wfd.ftLastWriteTime);
390
391 /* Move file */
392 if (MoveFileW(szFullName, DeletedFileName))
393 hr = S_OK;
394 else
396
397 if (SUCCEEDED(hr))
398 {
399 RECYCLEBINFILEIDENTITY ident = { pDeletedFile->DeletionTime, DeletedFileName };
400 CRecycleBin_NotifyRecycled(szFullName, &wfd, &ident);
401 }
402
403cleanup:
404 if (pHeader)
408 CoTaskMemFree(szFullName);
409 return hr;
410}
EXTERN_C void CRecycleBin_NotifyRecycled(LPCWSTR OrigPath, const WIN32_FIND_DATAW *pFind, const RECYCLEBINFILEIDENTITY *pFI)
int tolower(int c)
Definition: utclib.c:902
DWORD ClusterSize
Definition: format.c:67
CStringW m_Folder
CStringW m_VolumePath
wcscpy
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define TRUE
Definition: types.h:120
#define UnmapViewOfFile
Definition: compat.h:746
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetFilePointer
Definition: compat.h:743
#define SetLastError(x)
Definition: compat.h:752
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define GetFileSizeEx
Definition: compat.h:757
#define WideCharToMultiByte
Definition: compat.h:111
#define MapViewOfFile
Definition: compat.h:745
#define ERROR_INVALID_NAME
Definition: compat.h:103
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI GetDiskFreeSpaceW(IN LPCWSTR lpRootPathName, OUT LPDWORD lpSectorsPerCluster, OUT LPDWORD lpBytesPerSector, OUT LPDWORD lpNumberOfFreeClusters, OUT LPDWORD lpTotalNumberOfClusters)
Definition: disk.c:173
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:896
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1104
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
GLenum GLsizei len
Definition: glext.h:6722
FxContextHeader * pHeader
Definition: handleapi.cpp:604
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_CRTIMP wchar_t *__cdecl _ultow(_In_ unsigned long _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
_In_ HANDLE hFile
Definition: mswsock.h:90
#define SEC_COMMIT
Definition: mmtypes.h:100
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
struct _INFO2_HEADER * PINFO2_HEADER
struct _DELETED_FILE_RECORD * PDELETED_FILE_RECORD
struct _DELETED_FILE_RECORD DELETED_FILE_RECORD
HRESULT hr
Definition: shlfolder.c:183
CHAR FileNameA[MAX_PATH]
Definition: recyclebin_v5.h:15
WCHAR FileNameW[MAX_PATH]
Definition: recyclebin_v5.h:20
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2309 u
DWORD dwAttributes
Definition: vdmdbg.h:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define ZeroMemory
Definition: winbase.h:1737
#define FILE_END
Definition: winbase.h:115
#define FILE_MAP_WRITE
Definition: winbase.h:155
#define INVALID_FILE_SIZE
Definition: winbase.h:574
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD _Out_opt_ LPSTR * lpFilePart
Definition: winbase.h:3100
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ EmptyRecycleBin()

STDMETHODIMP RecycleBin5::EmptyRecycleBin ( )
override

Definition at line 412 of file recyclebin_v5.cpp.

413{
414 TRACE("(%p)\n", this);
415
416 while (TRUE)
417 {
418 IRecycleBinEnumList *prbel;
419 HRESULT hr = EnumObjects(&prbel);
420 if (!SUCCEEDED(hr))
421 return hr;
422
423 IRecycleBinFile *prbf;
424 hr = prbel->Next(1, &prbf, NULL);
425 prbel->Release();
426 if (hr == S_FALSE)
427 return S_OK;
428 hr = prbf->Delete();
429 prbf->Release();
430 if (!SUCCEEDED(hr))
431 return hr;
432 }
433}
STDMETHODIMP EnumObjects(_Out_ IRecycleBinEnumList **ppEnumList) override
ULONG Release()
#define S_FALSE
Definition: winerror.h:2357

◆ EnumObjects()

STDMETHODIMP RecycleBin5::EnumObjects ( _Out_ IRecycleBinEnumList **  ppEnumList)
override

Definition at line 435 of file recyclebin_v5.cpp.

436{
437 TRACE("(%p, %p)\n", this, ppEnumList);
438
439 IUnknown *pUnk;
441 if (!SUCCEEDED(hr))
442 return hr;
443
444 IRecycleBinEnumList *prbel;
445 hr = pUnk->QueryInterface(IID_IRecycleBinEnumList, (void **)&prbel);
446 if (SUCCEEDED(hr))
447 {
449 *ppEnumList = prbel;
450 }
451
452 pUnk->Release();
453 return hr;
454}
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
nsresult QueryInterface(nsIIDRef riid, void **result)
nsrefcnt Release()
EXTERN_C const IID IID_IRecycleBinEnumList
Definition: recyclebin.h:240
EXTERN_C HRESULT RecycleBin5Enum_Constructor(_In_ IRecycleBin5 *prb, _In_ HANDLE hInfo, _In_ HANDLE hInfoMapped, _In_ LPCWSTR szPrefix, _Out_ IUnknown **ppUnknown)

Referenced by EmptyRecycleBin().

◆ GetDirectory()

STDMETHODIMP RecycleBin5::GetDirectory ( LPWSTR  szPath)
inlineoverride

Definition at line 146 of file recyclebin_v5.cpp.

147 {
148 if (!m_Folder[0])
149 return E_UNEXPECTED;
151 return S_OK;
152 }
#define lstrcpynW
Definition: compat.h:738
LPCWSTR szPath
Definition: env.c:37
#define E_UNEXPECTED
Definition: winerror.h:2456

◆ Init()

HRESULT RecycleBin5::Init ( _In_ LPCWSTR  VolumePath)

Definition at line 674 of file recyclebin_v5.cpp.

675{
676 DWORD FileSystemFlags;
677 LPCWSTR RecycleBinDirectory;
678 HANDLE tokenHandle = INVALID_HANDLE_VALUE;
679 PTOKEN_USER TokenUserInfo = NULL;
680 LPWSTR StringSid = NULL;
681 DWORD Needed;
682 INT len;
683 HRESULT hr;
684
685 m_VolumePath = VolumePath;
686
687 /* Get information about file system */
688 if (!GetVolumeInformationW(VolumePath, NULL, 0, NULL, NULL, &FileSystemFlags, NULL, 0))
689 {
691 goto cleanup;
692 }
693
694 if (!(FileSystemFlags & FILE_PERSISTENT_ACLS))
695 {
696 RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITHOUT_ACL;
697 }
698 else
699 {
700 RecycleBinDirectory = RECYCLE_BIN_DIRECTORY_WITH_ACL;
701
702 /* Get user SID */
703 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle))
704 {
706 goto cleanup;
707 }
708 if (GetTokenInformation(tokenHandle, TokenUser, NULL, 0, &Needed))
709 {
710 hr = E_FAIL;
711 goto cleanup;
712 }
714 {
716 goto cleanup;
717 }
718 TokenUserInfo = (PTOKEN_USER)HeapAlloc(GetProcessHeap(), 0, Needed);
719 if (!TokenUserInfo)
720 {
722 goto cleanup;
723 }
724 if (!GetTokenInformation(tokenHandle, TokenUser, TokenUserInfo, (DWORD)Needed, &Needed))
725 {
727 goto cleanup;
728 }
729 if (!ConvertSidToStringSidW(TokenUserInfo->User.Sid, &StringSid))
730 {
732 goto cleanup;
733 }
734 }
735
736 m_Folder = VolumePath;
737 m_Folder += RecycleBinDirectory;
738 if (StringSid)
739 {
740 m_Folder += L'\\';
741 m_Folder += StringSid;
742 }
745
749 {
751 hr = RecycleBin5_Create(m_Folder, TokenUserInfo ? TokenUserInfo->User.Sid : NULL);
753 if (!SUCCEEDED(hr))
754 goto cleanup;
756 }
757
759 {
761 goto cleanup;
762 }
763
765 if (!m_hInfoMapped)
766 {
768 goto cleanup;
769 }
770
772 hr = S_OK;
773
774cleanup:
775 if (tokenHandle != INVALID_HANDLE_VALUE)
776 CloseHandle(tokenHandle);
777 HeapFree(GetProcessHeap(), 0, TokenUserInfo);
778 if (StringSid)
779 LocalFree(StringSid);
780 return hr;
781}
int GetLength() const noexcept
Definition: atlsimpstr.h:362
CStringT Left(int nCount) const
Definition: cstringt.h:776
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3583
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define GetCurrentProcess()
Definition: compat.h:759
#define GENERIC_READ
Definition: compat.h:135
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define FILE_PERSISTENT_ACLS
Definition: from_kernel.h:236
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define GENERIC_WRITE
Definition: nt_native.h:90
#define RECYCLE_BIN_DIRECTORY_WITH_ACL
#define RECYCLE_BIN_FILE_NAME
#define RECYCLE_BIN_DIRECTORY_WITHOUT_ACL
static HRESULT RecycleBin5_Create(_In_ LPCWSTR Folder, _In_ PSID OwnerSid OPTIONAL)
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
int32_t INT
Definition: typedefs.h:58
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
struct _TOKEN_USER * PTOKEN_USER
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenUser
Definition: setypes.h:966

Referenced by RecycleBin5_Constructor().

◆ OnClosing()

STDMETHODIMP RecycleBin5::OnClosing ( _In_ IRecycleBinEnumList *  prbel)
override

Definition at line 545 of file recyclebin_v5.cpp.

546{
547 TRACE("(%p, %p)\n", this, prbel);
549 return S_OK;
550}

◆ QueryInterface()

STDMETHODIMP RecycleBin5::QueryInterface ( _In_ REFIID  riid,
_Out_ void **  ppvObject 
)
override

Definition at line 175 of file recyclebin_v5.cpp.

176{
177 TRACE("(%p, %s, %p)\n", this, debugstr_guid(&riid), ppvObject);
178
179 if (!ppvObject)
180 return E_POINTER;
181
183 *ppvObject = static_cast<IRecycleBin5 *>(this);
185 *ppvObject = static_cast<IRecycleBin5 *>(this);
186 else
187 {
188 *ppvObject = NULL;
189 return E_NOINTERFACE;
190 }
191
192 AddRef();
193 return S_OK;
194}
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:241
EXTERN_C const IID IID_IRecycleBin5
Definition: recyclebin_v5.h:28
interface IRecycleBin5 IRecycleBin5
Definition: recyclebin_v5.h:27
_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

◆ RemoveFromDatabase()

STDMETHODIMP RecycleBin5::RemoveFromDatabase ( _In_ LPCWSTR  pDeletedFileName,
_In_ DELETED_FILE_RECORD pDeletedFile 
)
override

Definition at line 491 of file recyclebin_v5.cpp.

494{
497 DELETED_FILE_RECORD *pRecord, *pLast;
498 DWORD dwEntries, i;
499
500 TRACE("(%p, %s, %p)\n", this, debugstr_w(pDeletedFileName), pDeletedFile);
501
502 if (m_EnumeratorCount != 0)
504
506 if (!pHeader)
508
509 FileSize.u.LowPart = GetFileSize(m_hInfo, &FileSize.u.HighPart);
510 if (FileSize.u.LowPart == 0)
511 {
514 }
515 dwEntries = (DWORD)((FileSize.QuadPart - sizeof(INFO2_HEADER)) / sizeof(DELETED_FILE_RECORD));
516
517 pRecord = (DELETED_FILE_RECORD *)(pHeader + 1);
518 for (i = 0; i < dwEntries; i++)
519 {
520 if (pRecord->dwRecordUniqueId == pDeletedFile->dwRecordUniqueId)
521 {
522 /* Clear last entry in the file */
523 MoveMemory(pRecord, pRecord + 1, (dwEntries - i - 1) * sizeof(DELETED_FILE_RECORD));
524 pLast = pRecord + (dwEntries - i - 1);
525 ZeroMemory(pLast, sizeof(DELETED_FILE_RECORD));
527
528 /* Resize file */
533 if (!m_hInfoMapped)
535 dwEntries--;
536 return FAILED((int)dwEntries) ? INT_MAX : dwEntries;
537 }
538 pRecord++;
539 }
540
543}
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 INT_MAX
Definition: intsafe.h:150
#define FAILED(hr)
Definition: intsafe.h:51
long LONG
Definition: pedump.c:60
#define MoveMemory
Definition: winbase.h:1734

Referenced by Delete(), and Restore().

◆ Restore()

STDMETHODIMP RecycleBin5::Restore ( _In_ LPCWSTR  pDeletedFileName,
_In_ DELETED_FILE_RECORD pDeletedFile 
)
override

Definition at line 472 of file recyclebin_v5.cpp.

475{
476
477 TRACE("(%p, %s, %p)\n", this, debugstr_w(pDeletedFileName), pDeletedFile);
478
479 int res = SHELL_SingleFileOperation(NULL, FO_MOVE, pDeletedFileName, pDeletedFile->FileNameW, 0);
480 if (res)
481 {
482 ERR("SHFileOperationW failed with 0x%x\n", res);
483 return E_FAIL;
484 }
485 res = RemoveFromDatabase(pDeletedFileName, pDeletedFile);
486 if (res == 0)
487 SHUpdateRecycleBinIcon(); // Full --> Empty
488 return res;
489}
#define ERR(fmt,...)
Definition: precomp.h:57
static int SHELL_SingleFileOperation(HWND hWnd, UINT Op, LPCWSTR pszFrom, LPCWSTR pszTo, FILEOP_FLAGS Flags)
#define FO_MOVE
Definition: shellapi.h:137

◆ STDMETHODIMP_() [1/2]

RecycleBin5::STDMETHODIMP_ ( ULONG  )
override

◆ STDMETHODIMP_() [2/2]

RecycleBin5::STDMETHODIMP_ ( ULONG  )
override

Member Data Documentation

◆ m_EnumeratorCount

DWORD RecycleBin5::m_EnumeratorCount
protected

Definition at line 170 of file recyclebin_v5.cpp.

Referenced by DeleteFile(), EnumObjects(), OnClosing(), and RemoveFromDatabase().

◆ m_Folder

CStringW RecycleBin5::m_Folder
protected

Definition at line 172 of file recyclebin_v5.cpp.

Referenced by DeleteFile(), EnumObjects(), GetDirectory(), and Init().

◆ m_hInfo

HANDLE RecycleBin5::m_hInfo
protected

Definition at line 168 of file recyclebin_v5.cpp.

Referenced by DeleteFile(), EnumObjects(), Init(), RemoveFromDatabase(), and ~RecycleBin5().

◆ m_hInfoMapped

HANDLE RecycleBin5::m_hInfoMapped
protected

Definition at line 169 of file recyclebin_v5.cpp.

Referenced by DeleteFile(), EnumObjects(), Init(), RemoveFromDatabase(), and ~RecycleBin5().

◆ m_ref

LONG RecycleBin5::m_ref
protected

Definition at line 167 of file recyclebin_v5.cpp.

Referenced by STDMETHODIMP_().

◆ m_VolumePath

CStringW RecycleBin5::m_VolumePath
protected

Definition at line 171 of file recyclebin_v5.cpp.

Referenced by DeleteFile(), and Init().


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