From 2d0e1c313a49ef334e8062f7a90e3868ed20918e Mon Sep 17 00:00:00 2001 From: Tyler Gibson Date: Thu, 24 Dec 2015 03:54:50 +0000 Subject: [PATCH] Adding check for Windows version and alternate flags for Windows Vista/7 --- atom/common/platform_util_win.cc | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/atom/common/platform_util_win.cc b/atom/common/platform_util_win.cc index cca392952e65..735e974d1f8a 100644 --- a/atom/common/platform_util_win.cc +++ b/atom/common/platform_util_win.cc @@ -340,13 +340,26 @@ bool MoveItemToTrash(const base::FilePath& path) { // Elevation prompt enabled for UAC protected files. This overrides the // SILENT, NO_UI and NOERRORUI flags. - if (FAILED(pfo->SetOperationFlags(FOF_NO_UI | - FOF_ALLOWUNDO | - FOF_NOERRORUI | - FOF_SILENT | - FOFX_SHOWELEVATIONPROMPT | - FOFX_RECYCLEONDELETE))) - return false; + + if (base::win::GetVersion() >= base::win::VERSION_WIN8) { + // Windows 8 introduces the flag RECYCLEONDELETE and deprecates the + // ALLOWUNDO in favor of ADDUNDORECORD. + if (FAILED(pfo->SetOperationFlags(FOF_NO_UI | + FOFX_ADDUNDORECORD | + FOF_NOERRORUI | + FOF_SILENT | + FOFX_SHOWELEVATIONPROMPT | + FOFX_RECYCLEONDELETE))) + return false; + } else { + // For Windows 7 and Vista, RecycleOnDelete is the default behavior. + if (FAILED(pfo->SetOperationFlags(FOF_NO_UI | + FOF_ALLOWUNDO | + FOF_NOERRORUI | + FOF_SILENT | + FOFX_SHOWELEVATIONPROMPT))) + return false; + } // Create an IShellItem from the supplied source path. base::win::ScopedComPtr delete_item;