From 10d3b0bdd98cfba6a8fd2b5ac37f66f87f44b469 Mon Sep 17 00:00:00 2001 From: Nicole Cordes Date: Sun, 14 Oct 2018 21:12:42 +0200 Subject: [PATCH] [BUGFIX] Decouple GeneralUtility::rmdir from Environment::isWindows() To be able to call rmdir without an initialized Environment instance, the check if a Windows system is used, is decoupled. This allows to call GeneralUtility::rmdir e.g. in typo3/testing-framework. Resolves: #86655 Releases: master Change-Id: Ica1feafbd9a07005c4b653ef2fe1153fba4b9417 Reviewed-on: https://review.typo3.org/58631 Tested-by: TYPO3com Reviewed-by: Susanne Moog Tested-by: Susanne Moog Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn Reviewed-by: Benni Mack Tested-by: Benni Mack --- typo3/sysext/core/Classes/Utility/GeneralUtility.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index f68d5b99f553..5e6073a54ebb 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -2187,6 +2187,7 @@ public static function rmdir($path, $removeNonEmpty = false) $OK = false; // Remove trailing slash $path = preg_replace('|/$|', '', $path); + $isWindows = DIRECTORY_SEPARATOR === '\\'; if (file_exists($path)) { $OK = true; if (!is_link($path) && is_dir($path)) { @@ -2202,7 +2203,7 @@ public static function rmdir($path, $removeNonEmpty = false) if ($OK) { $OK = @rmdir($path); } - } elseif (is_link($path) && is_dir($path) && Environment::isWindows()) { + } elseif (is_link($path) && is_dir($path) && $isWindows) { $OK = @rmdir($path); } else { // If $path is a file, simply remove it @@ -2211,7 +2212,7 @@ public static function rmdir($path, $removeNonEmpty = false) clearstatcache(); } elseif (is_link($path)) { $OK = @unlink($path); - if (!$OK && Environment::isWindows()) { + if (!$OK && $isWindows) { // Try to delete dead folder links on Windows systems $OK = @rmdir($path); }