[BUGFIX] Improve file handling on Windows systems 72/36372/2
authorNicole Cordes <typo3@cordes.co>
Thu, 29 Jan 2015 14:26:43 +0000 (15:26 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 29 Jan 2015 17:19:49 +0000 (18:19 +0100)
Calling unlink() on a symlink that points to a directory
fails on Windows. Solution is to use rmdir() instead to
remove the symlink.
Furthermore it fixes a wrong usage of DIRECTORY_SEPARATOR
within the FileHandlingUtility.

Releases: master, 6.2
Resolves: #64409
Change-Id: Idc6ff3eb1214ed8f5cb0f69f15a2d5a6a3dcfafe
Reviewed-on: http://review.typo3.org/36372
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/extensionmanager/Classes/Utility/FileHandlingUtility.php

index 9018bf6..70c0ad8 100755 (executable)
@@ -2910,6 +2910,8 @@ Connection: close
                                if ($OK) {
                                        $OK = @rmdir($path);
                                }
+                       } elseif (is_link($path) && is_dir($path) && TYPO3_OS === 'WIN') {
+                               $OK = rmdir($path);
                        } else {
                                // If $path is a file, simply remove it
                                $OK = unlink($path);
index 24fd5b3..caa3502 100644 (file)
@@ -245,8 +245,9 @@ class FileHandlingUtility implements \TYPO3\CMS\Core\SingletonInterface {
         * @return void
         */
        public function removeDirectory($extDirPath) {
-               $extensionPathWithoutTrailingSlash = rtrim($extDirPath, DIRECTORY_SEPARATOR);
-               if (is_link($extensionPathWithoutTrailingSlash)) {
+               $extDirPath = GeneralUtility::fixWindowsFilePath($extDirPath);
+               $extensionPathWithoutTrailingSlash = rtrim($extDirPath, '/');
+               if (is_link($extensionPathWithoutTrailingSlash) && TYPO3_OS !== 'WIN') {
                        $result = unlink($extensionPathWithoutTrailingSlash);
                } else {
                        $result = GeneralUtility::rmdir($extDirPath, TRUE);