ReactOS 0.4.15-dev-8434-g155a7c7
CRecycleBin.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CRecycleBin
 

Functions

BOOL TRASH_CanTrashFile (LPCWSTR wszPath)
 
BOOL TRASH_TrashFile (LPCWSTR wszPath)
 
HRESULT CRecyclerDropTarget_CreateInstance (REFIID riid, LPVOID *ppvOut)
 

Function Documentation

◆ CRecyclerDropTarget_CreateInstance()

HRESULT CRecyclerDropTarget_CreateInstance ( REFIID  riid,
LPVOID ppvOut 
)

Definition at line 183 of file CRecyclerDropTarget.cpp.

184{
185 return ShellObjectCreator<CRecyclerDropTarget>(riid, ppvOut);
186}
REFIID riid
Definition: atlbase.h:39

Referenced by CRecycleBin::CreateViewObject(), and CDefaultContextMenu::DoDelete().

◆ TRASH_CanTrashFile()

BOOL TRASH_CanTrashFile ( LPCWSTR  wszPath)

Tests whether a file can be trashed

Parameters
wszPathPath to the file to be trash
Returns
TRUE if the file can be trashed, FALSE otherwise

Definition at line 937 of file CRecycleBin.cpp.

938{
939 LONG ret;
940 DWORD dwNukeOnDelete, dwType, VolSerialNumber, MaxComponentLength;
941 DWORD FileSystemFlags, dwSize, dwDisposition;
942 HKEY hKey;
943 WCHAR szBuffer[10];
944 WCHAR szKey[150] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\BitBucket\\Volume\\";
945
946 if (wszPath[1] != L':')
947 {
948 /* path is UNC */
949 return FALSE;
950 }
951
952 // Copy and retrieve the root path from get given string
953 WCHAR wszRootPathName[MAX_PATH];
954 StringCbCopyW(wszRootPathName, sizeof(wszRootPathName), wszPath);
955 PathStripToRootW(wszRootPathName);
956
957 // Test to see if the drive is fixed (non removable)
958 if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED)
959 {
960 /* no bitbucket on removable media */
961 return FALSE;
962 }
963
964 if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0))
965 {
966 ERR("GetVolumeInformationW failed with %u wszRootPathName=%s\n", GetLastError(), debugstr_w(wszRootPathName));
967 return FALSE;
968 }
969
970 swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber));
971 wcscat(szKey, szBuffer);
972
973 if (RegCreateKeyExW(HKEY_CURRENT_USER, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS)
974 {
975 ERR("RegCreateKeyExW failed\n");
976 return FALSE;
977 }
978
979 if (dwDisposition & REG_CREATED_NEW_KEY)
980 {
981 /* per default move to bitbucket */
982 dwNukeOnDelete = 0;
983 RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
984 /* per default unlimited size */
985 dwSize = -1;
986 RegSetValueExW(hKey, L"MaxCapacity", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD));
988 return TRUE;
989 }
990 else
991 {
992 dwSize = sizeof(dwNukeOnDelete);
993 ret = RegQueryValueExW(hKey, L"NukeOnDelete", NULL, &dwType, (LPBYTE)&dwNukeOnDelete, &dwSize);
994 if (ret != ERROR_SUCCESS)
995 {
997 {
998 /* restore key and enable bitbucket */
999 dwNukeOnDelete = 0;
1000 RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
1001 }
1003 return TRUE;
1004 }
1005 else if (dwNukeOnDelete)
1006 {
1007 /* do not delete to bitbucket */
1009 return FALSE;
1010 }
1011 /* FIXME
1012 * check if bitbucket is full
1013 */
1015 return TRUE;
1016 }
1017}
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
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
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
#define swprintf
Definition: precomp.h:40
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HIWORD(l)
Definition: typedefs.h:247
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DRIVE_FIXED
Definition: winbase.h:252
#define HKEY_CURRENT_USER
Definition: winreg.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by delete_files().

◆ TRASH_TrashFile()

BOOL TRASH_TrashFile ( LPCWSTR  wszPath)

Definition at line 1020 of file CRecycleBin.cpp.

1021{
1022 TRACE("(%s)\n", debugstr_w(wszPath));
1023 return DeleteFileToRecycleBin(wszPath);
1024}
#define DeleteFileToRecycleBin
Definition: recyclebin.h:85
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by delete_files().