ReactOS  0.4.15-dev-985-gd905dd5
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 182 of file CRecyclerDropTarget.cpp.

183 {
184  return ShellObjectCreator<CRecyclerDropTarget>(riid, ppvOut);
185 }
REFIID riid
Definition: precomp.h:44

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 896 of file CRecycleBin.cpp.

897 {
898  LONG ret;
899  DWORD dwNukeOnDelete, dwType, VolSerialNumber, MaxComponentLength;
900  DWORD FileSystemFlags, dwSize, dwDisposition;
901  HKEY hKey;
902  WCHAR szBuffer[10];
903  WCHAR szKey[150] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\BitBucket\\Volume\\";
904 
905  if (wszPath[1] != L':')
906  {
907  /* path is UNC */
908  return FALSE;
909  }
910 
911  // Copy and retrieve the root path from get given string
912  WCHAR wszRootPathName[MAX_PATH];
913  StringCbCopyW(wszRootPathName, sizeof(wszRootPathName), wszPath);
914  PathStripToRootW(wszRootPathName);
915 
916  // Test to see if the drive is fixed (non removable)
917  if (GetDriveTypeW(wszRootPathName) != DRIVE_FIXED)
918  {
919  /* no bitbucket on removable media */
920  return FALSE;
921  }
922 
923  if (!GetVolumeInformationW(wszRootPathName, NULL, 0, &VolSerialNumber, &MaxComponentLength, &FileSystemFlags, NULL, 0))
924  {
925  ERR("GetVolumeInformationW failed with %u wszRootPathName=%s\n", GetLastError(), debugstr_w(wszRootPathName));
926  return FALSE;
927  }
928 
929  swprintf(szBuffer, L"%04X-%04X", LOWORD(VolSerialNumber), HIWORD(VolSerialNumber));
930  wcscat(szKey, szBuffer);
931 
932  if (RegCreateKeyExW(HKEY_CURRENT_USER, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition) != ERROR_SUCCESS)
933  {
934  ERR("RegCreateKeyExW failed\n");
935  return FALSE;
936  }
937 
938  if (dwDisposition & REG_CREATED_NEW_KEY)
939  {
940  /* per default move to bitbucket */
941  dwNukeOnDelete = 0;
942  RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
943  /* per default unlimited size */
944  dwSize = -1;
945  RegSetValueExW(hKey, L"MaxCapacity", 0, REG_DWORD, (LPBYTE)&dwSize, sizeof(DWORD));
946  RegCloseKey(hKey);
947  return TRUE;
948  }
949  else
950  {
951  dwSize = sizeof(dwNukeOnDelete);
952  ret = RegQueryValueExW(hKey, L"NukeOnDelete", NULL, &dwType, (LPBYTE)&dwNukeOnDelete, &dwSize);
953  if (ret != ERROR_SUCCESS)
954  {
955  if (ret == ERROR_FILE_NOT_FOUND)
956  {
957  /* restore key and enable bitbucket */
958  dwNukeOnDelete = 0;
959  RegSetValueExW(hKey, L"NukeOnDelete", 0, REG_DWORD, (LPBYTE)&dwNukeOnDelete, sizeof(DWORD));
960  }
961  RegCloseKey(hKey);
962  return TRUE;
963  }
964  else if (dwNukeOnDelete)
965  {
966  /* do not delete to bitbucket */
967  RegCloseKey(hKey);
968  return FALSE;
969  }
970  /* FIXME
971  * check if bitbucket is full
972  */
973  RegCloseKey(hKey);
974  return TRUE;
975  }
976 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:728
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
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:4895
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
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
#define ERR(fmt,...)
Definition: debug.h:110
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
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define HIWORD(l)
Definition: typedefs.h:247
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define REG_DWORD
Definition: sdbapi.c:596
#define LOWORD(l)
Definition: pedump.c:82
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by delete_files().

◆ TRASH_TrashFile()

BOOL TRASH_TrashFile ( LPCWSTR  wszPath)

Definition at line 979 of file CRecycleBin.cpp.

980 {
981  TRACE("(%s)\n", debugstr_w(wszPath));
982  return DeleteFileToRecycleBin(wszPath);
983 }
#define debugstr_w
Definition: kernel32.h:32
#define DeleteFileToRecycleBin
Definition: recyclebin.h:82
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by delete_files().