Ejemplo n.º 1
0
 public static function tearDownAfterClass()
 {
     foreach (self::$testDirs as $dir) {
         chmod($dir, 0777);
         \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($dir, TRUE);
     }
 }
Ejemplo n.º 2
0
 /**
  * Unset all additional properties of test classes to help PHP
  * garbage collection. This reduces memory footprint with lots
  * of tests.
  *
  * If owerwriting tearDown() in test classes, please call
  * parent::tearDown() at the end. Unsetting of own properties
  * is not needed this way.
  *
  * @throws \RuntimeException
  * @return void
  */
 protected function tearDown()
 {
     // Unset properties of test classes to safe memory
     $reflection = new \ReflectionObject($this);
     foreach ($reflection->getProperties() as $property) {
         $declaringClass = $property->getDeclaringClass()->getName();
         if (!$property->isStatic() && $declaringClass !== \TYPO3\CMS\Core\Tests\UnitTestCase::class && $declaringClass !== \TYPO3\CMS\Core\Tests\BaseTestCase::class && strpos($property->getDeclaringClass()->getName(), 'PHPUnit_') !== 0) {
             $propertyName = $property->getName();
             unset($this->{$propertyName});
         }
     }
     unset($reflection);
     // Delete registered test files and directories
     foreach ($this->testFilesToDelete as $absoluteFileName) {
         $absoluteFileName = GeneralUtility::fixWindowsFilePath(PathUtility::getCanonicalPath($absoluteFileName));
         if (!GeneralUtility::validPathStr($absoluteFileName)) {
             throw new \RuntimeException('tearDown() cleanup: Filename contains illegal characters', 1410633087);
         }
         if (!StringUtility::beginsWith($absoluteFileName, PATH_site . 'typo3temp/')) {
             throw new \RuntimeException('tearDown() cleanup:  Files to delete must be within typo3temp/', 1410633412);
         }
         // file_exists returns false for links pointing to not existing targets, so handle links before next check.
         if (@is_link($absoluteFileName) || @is_file($absoluteFileName)) {
             unlink($absoluteFileName);
         } elseif (@is_dir($absoluteFileName)) {
             GeneralUtility::rmdir($absoluteFileName, true);
         } else {
             throw new \RuntimeException('tearDown() cleanup: File, link or directory does not exist', 1410633510);
         }
     }
     $this->testFilesToDelete = array();
 }
Ejemplo n.º 3
0
 /**
  * Flush all processed files to be used for debugging mainly.
  *
  * @return void
  */
 public function flushProcessedFilesCommand()
 {
     foreach ($this->getStorageRepository()->findAll() as $storage) {
         // This only works for local driver
         if ($storage->getDriverType() === 'Local') {
             $this->outputLine();
             $this->outputLine(sprintf('%s (%s)', $storage->getName(), $storage->getUid()));
             $this->outputLine('--------------------------------------------');
             $this->outputLine();
             #$storage->getProcessingFolder()->delete(TRUE); // will not work
             // Well... not really FAL friendly but straightforward for Local drivers.
             $processedDirectoryPath = PATH_site . $storage->getProcessingFolder()->getPublicUrl();
             $fileIterator = new FilesystemIterator($processedDirectoryPath, FilesystemIterator::SKIP_DOTS);
             $numberOfProcessedFiles = iterator_count($fileIterator);
             GeneralUtility::rmdir($processedDirectoryPath, TRUE);
             GeneralUtility::mkdir($processedDirectoryPath);
             // recreate the directory.
             $message = sprintf('Done! Removed %s processed file(s).', $numberOfProcessedFiles);
             $this->outputLine($message);
             // Remove the record as well.
             $record = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('count(*) AS numberOfProcessedFiles', 'sys_file_processedfile', 'storage = ' . $storage->getUid());
             $this->getDatabaseConnection()->exec_DELETEquery('sys_file_processedfile', 'storage = ' . $storage->getUid());
             $message = sprintf('Done! Removed %s records from "sys_file_processedfile".', $record['numberOfProcessedFiles']);
             $this->outputLine($message);
         }
     }
     // Remove possible remaining "sys_file_processedfile"
     $query = 'TRUNCATE sys_file_processedfile';
     $this->getDatabaseConnection()->sql_query($query);
 }
Ejemplo n.º 4
0
 /**
  * This clear cache implementation follows a pretty brutal approach.
  * Goal is to reliably get rid of cache entries, even if some broken
  * extension is loaded that would kill the backend 'clear cache' action.
  *
  * Therefor this method "knows" implementation details of the cache
  * framework and uses them to clear all file based cache (typo3temp/Cache)
  * and database caches (tables prefixed with cf_) manually.
  *
  * After that ext_tables and ext_localconf of extensions are loaded, those
  * may register additional caches in the caching framework with different
  * backend, and will then clear them with the usual flush() method.
  *
  * @return void
  */
 public function clearAll()
 {
     // Delete typo3temp/Cache
     GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache', TRUE);
     $bootstrap = \TYPO3\CMS\Core\Core\Bootstrap::getInstance();
     $bootstrap->unregisterClassLoader();
     \TYPO3\CMS\Core\Cache\Cache::flagCachingFrameworkForReinitialization();
     $bootstrap->initializeClassLoader()->initializeCachingFramework()->initializeClassLoaderCaches()->initializePackageManagement('TYPO3\\CMS\\Core\\Package\\PackageManager');
     // Get all table names starting with 'cf_' and truncate them
     $database = $this->getDatabaseConnection();
     $tables = $database->admin_get_tables();
     foreach ($tables as $table) {
         $tableName = $table['Name'];
         if (substr($tableName, 0, 3) === 'cf_') {
             $database->exec_TRUNCATEquery($tableName);
         }
     }
     // From this point on, the code may fatal, if some broken extension is loaded.
     // Use bootstrap to load all ext_localconf and ext_tables
     $bootstrap->loadTypo3LoadedExtAndExtLocalconf(FALSE)->applyAdditionalConfigurationSettings()->initializeTypo3DbGlobal()->loadExtensionTables(FALSE);
     // The cache manager is already instantiated in the install tool
     // with some hacked settings to disable caching of extbase and fluid.
     // We want a "fresh" object here to operate on a different cache setup.
     // cacheManager implements SingletonInterface, so the only way to get a "fresh"
     // instance is by circumventing makeInstance and/or the objectManager and
     // using new directly!
     $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
     new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
     $cacheManager->flushCaches();
 }
Ejemplo n.º 5
0
 /**
  * @return void
  */
 public function tearDown()
 {
     foreach ($this->fakedExtensions as $extension => $dummy) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_site . 'typo3temp/' . $extension, TRUE);
     }
     parent::tearDown();
 }
Ejemplo n.º 6
0
 protected function tearDown()
 {
     if (!empty($this->extension) && $this->extension->getExtensionKey() != null) {
         GeneralUtility::rmdir($this->extension->getExtensionDir(), true);
     }
     parent::tearDown();
 }
Ejemplo n.º 7
0
 /**
  *
  * @param string $params
  * @param type $pObj
  *
  * @todo add typehinting
  */
 function clearCachePostProc($params, &$pObj)
 {
     if (isset($params['cacheCmd']) && ($params['cacheCmd'] = 'pages')) {
         GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache/Data/DynCss', TRUE);
         GeneralUtility::rmdir(PATH_site . 'typo3temp/DynCss', TRUE);
     }
 }
Ejemplo n.º 8
0
 /**
  * Tear down
  */
 public function tearDown()
 {
     foreach ($this->testDirs as $dir) {
         chmod($dir, 0777);
         \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($dir, TRUE);
     }
     parent::tearDown();
 }
Ejemplo n.º 9
0
 /**
  * Clean up
  * Warning: Since phpunit itself is php and we are fiddling with php
  * autoloader code here, the tests are a bit fragile. This tearDown
  * method ensures that all main classes are available again during
  * tear down of a testcase.
  * This construct will fail if the class under test is changed and
  * not compatible anymore. Make sure to always run the whole test
  * suite if fiddling with the autoloader unit tests to ensure that
  * there is no fatal error thrown in other unit test classes triggered
  * by errors in this one.
  */
 public function tearDown()
 {
     $GLOBALS['typo3CacheManager'] = $this->typo3CacheManager;
     \TYPO3\CMS\Core\Core\ClassLoader::unregisterAutoloader();
     \TYPO3\CMS\Core\Core\ClassLoader::registerAutoloader();
     foreach ($this->fakedExtensions as $extension) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_site . 'typo3temp/' . $extension, TRUE);
     }
 }
Ejemplo n.º 10
0
 /**
  * Tear down
  */
 public function tearDown()
 {
     foreach ($this->testNodesToDelete as $node) {
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
         }
     }
     parent::tearDown();
 }
Ejemplo n.º 11
0
 /**
  * Execute signalSlot 'afterExtensionUninstall'
  *
  * @param string $extensionName
  */
 public static function executeOnSignal($extensionName = null)
 {
     if ($extensionName !== 'lib_js_analytics') {
         return;
     }
     // Cleanup uploads-folder (containing downloaded analytics.js) and extension-configuration
     GeneralUtility::rmdir(GeneralUtility::getFileAbsFileName('uploads/tx_libjsanalytics/'), true);
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $configurationManager = $objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
     $configurationManager->removeLocalConfigurationKeysByPath(['EXT/extConf/lib_js_analytics']);
 }
Ejemplo n.º 12
0
 /**
  * Clear all caches.
  *
  * @param bool $hard
  * @return void
  */
 public function clearAllCaches($hard = FALSE)
 {
     if (!$hard) {
         $this->dataHandler->clear_cacheCmd('all');
     } else {
         GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache', TRUE);
         $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
         $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
         new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
         $cacheManager->flushCaches();
     }
 }
Ejemplo n.º 13
0
 /**
  * Deletes DynCss folders inside typo3temp/.
  *
  * @param array                                    $params
  * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj
  */
 public function clearCachePostProc(array $params, DataHandler &$pObj)
 {
     if (!isset($params['cacheCmd'])) {
         return;
     }
     switch ($params['cacheCmd']) {
         case 'dyncss':
             GeneralUtility::rmdir(PATH_site . 'typo3temp/Cache/Data/DynCss', true);
             GeneralUtility::rmdir(PATH_site . 'typo3temp/DynCss', true);
             break;
         default:
     }
 }
 /**
  * Remove all directory and files within the test instance folder.
  *
  * @return void
  */
 protected function removeOldInstanceIfExists()
 {
     $dir = scandir($this->instancePath);
     foreach ($dir as $entry) {
         if (is_dir($this->instancePath . '/' . $entry) && $entry != '..' && $entry != '.') {
             GeneralUtility::rmdir($this->instancePath . '/' . $entry, TRUE);
         } else {
             if (is_file($this->instancePath . '/' . $entry)) {
                 unlink($this->instancePath . '/' . $entry);
             }
         }
     }
 }
 /**
  * @return void
  */
 public function tearDown()
 {
     foreach ($this->fakedExtensions as $extension => $dummy) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_site . 'typo3conf/ext/' . $extension, TRUE);
     }
     foreach ($this->resourcesToRemove as $resource) {
         if (file_exists($resource) && is_file($resource)) {
             unlink($resource);
         } elseif (file_exists($resource) && is_dir($resource)) {
             rmdir($resource);
         }
     }
     parent::tearDown();
 }
 public function tearDown()
 {
     ExtensionManagementUtility::clearExtensionKeyMap();
     foreach ($this->testFilesToDelete as $absoluteFileName) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($absoluteFileName);
     }
     if (file_exists(PATH_site . 'typo3temp/test_ext/')) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_site . 'typo3temp/test_ext/', TRUE);
     }
     ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
     ExtensionManagementUtilityAccessibleProxy::setCacheManager(NULL);
     $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->backUpPackageManager);
     \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
     parent::tearDown();
 }
Ejemplo n.º 17
0
 /**
  * clear Cache ajax handler
  *
  * @param array              $ajaxParams
  * @param AjaxRequestHandler $ajaxObj
  */
 public function clear($ajaxParams, AjaxRequestHandler $ajaxObj)
 {
     if ($this->isProduction() || !$this->isAdmin()) {
         return;
     }
     /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
     $cacheManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
     $cacheManager->getCache('autoloader')->flush();
     // clear autoload folder
     if (GeneralUtility::compat_version('7.0')) {
         $autoloadFolder = GeneralUtility::getFileAbsFileName('typo3temp/autoload/');
         if (is_dir($autoloadFolder)) {
             GeneralUtility::rmdir($autoloadFolder, true);
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * Render a CSV export request.
  *
  * @return boolean
  */
 public function render()
 {
     $objects = $this->templateVariableContainer->get('objects');
     // Make sure we have something to process...
     if (!empty($objects)) {
         // Initialization step.
         $this->initializeEnvironment($objects);
         $this->exportFileNameAndPath .= '.csv';
         // add extension to the file.
         // Write the exported data to a CSV file.
         $this->writeCsvFile($objects);
         // We must generate a zip archive since there are files included.
         if ($this->hasCollectedFiles()) {
             $this->writeZipFile();
             $this->sendZipHttpHeaders();
             readfile($this->zipFileNameAndPath);
         } else {
             $this->sendCsvHttpHeaders();
             readfile($this->exportFileNameAndPath);
         }
         GeneralUtility::rmdir($this->temporaryDirectory, TRUE);
     }
 }
Ejemplo n.º 19
0
 /**
  * Install translations for all selected languages for an extension
  *
  * @param string $extensionKey The extension key to install the translations for
  * @param string $language Language code of translation to fetch
  * @param string $mirrorUrl Mirror URL to fetch data from
  * @return boolean TRUE on success, error string on fauilure
  */
 public function updateTranslation($extensionKey, $language, $mirrorUrl)
 {
     $result = FALSE;
     try {
         $l10n = $this->fetchTranslation($extensionKey, $language, $mirrorUrl);
         if (is_array($l10n)) {
             $file = PATH_site . 'typo3temp' . DIRECTORY_SEPARATOR . $extensionKey . '-l10n-' . $language . '.zip';
             $path = 'l10n' . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $extensionKey . DIRECTORY_SEPARATOR;
             if (!is_dir(PATH_typo3conf . $path)) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep(PATH_typo3conf, $path);
             }
             \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($file, $l10n[0]);
             \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_typo3conf . $path . $extensionKey, TRUE);
             if ($this->unzipTranslationFile($file, PATH_typo3conf . $path)) {
                 $result = TRUE;
             }
         }
     } catch (\TYPO3\CMS\Core\Exception $exception) {
         // @todo logging
     }
     return $result;
 }
Ejemplo n.º 20
0
 /**
  * @test
  */
 public function getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys()
 {
     $directory = PATH_site . 'typo3temp/' . $this->getUniqueId('directory_');
     mkdir($directory);
     $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath(array(), $directory, '', true);
     $check = true;
     foreach ($filesAndDirectories as $md5 => $path) {
         if (!preg_match('/^[a-f0-9]{32}$/', $md5)) {
             $check = false;
         }
     }
     GeneralUtility::rmdir($directory);
     $this->assertTrue($check);
 }
Ejemplo n.º 21
0
 /**
  * Install translations for all selected languages for an extension
  *
  * @param string $extensionKey The extension key to install the translations for
  * @param string $language Language code of translation to fetch
  * @param string $mirrorUrl Mirror URL to fetch data from
  * @return bool TRUE on success, error string on failure
  */
 public function updateTranslation($extensionKey, $language, $mirrorUrl)
 {
     $result = FALSE;
     try {
         $l10n = $this->fetchTranslation($extensionKey, $language, $mirrorUrl);
         if (is_array($l10n)) {
             $absolutePathToZipFile = GeneralUtility::getFileAbsFileName('typo3temp/' . $extensionKey . '-l10n-' . $language . '.zip');
             $relativeLanguagePath = 'l10n' . '/' . $language . '/';
             $absoluteLanguagePath = GeneralUtility::getFileAbsFileName(PATH_typo3conf . $relativeLanguagePath);
             $absoluteExtensionLanguagePath = GeneralUtility::getFileAbsFileName(PATH_typo3conf . $relativeLanguagePath . $extensionKey . '/');
             if (empty($absolutePathToZipFile) || empty($absoluteLanguagePath) || empty($absoluteExtensionLanguagePath)) {
                 throw new \TYPO3\CMS\Lang\Exception\Language('Given path is invalid.', 1352565336);
             }
             if (!is_dir($absoluteLanguagePath)) {
                 GeneralUtility::mkdir_deep(PATH_typo3conf, $relativeLanguagePath);
             }
             GeneralUtility::writeFile($absolutePathToZipFile, $l10n[0]);
             if (is_dir($absoluteExtensionLanguagePath)) {
                 GeneralUtility::rmdir($absoluteExtensionLanguagePath, TRUE);
             }
             if ($this->unzipTranslationFile($absolutePathToZipFile, $absoluteLanguagePath)) {
                 $result = TRUE;
             }
         }
     } catch (\TYPO3\CMS\Core\Exception $exception) {
         // @todo logging
     }
     return $result;
 }
Ejemplo n.º 22
0
 /**
  * Removes a folder from this storage.
  *
  * @param \TYPO3\CMS\Core\Resource\Folder $folder
  * @param bool $deleteRecursively
  * @return boolean
  */
 public function deleteFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $deleteRecursively = FALSE)
 {
     $folderPath = $this->getAbsolutePath($folder);
     $result = \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($folderPath, $deleteRecursively);
     if ($result === FALSE) {
         throw new \TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException('Deleting folder "' . $folder->getIdentifier() . '" failed.', 1330119451);
     }
     return $result;
 }
Ejemplo n.º 23
0
 /**
  * @test
  */
 public function fixPermissionsCorrectlySetsPermissionsRecursive()
 {
     if (TYPO3_OS == 'WIN') {
         $this->markTestSkipped('fixPermissions() tests not available on Windows');
     }
     // Create and prepare test directory and file structure
     $baseDirectory = PATH_site . 'typo3temp/' . uniqid('test_');
     Utility\GeneralUtility::mkdir($baseDirectory);
     chmod($baseDirectory, 1751);
     Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/file', '42');
     chmod($baseDirectory . '/file', 482);
     Utility\GeneralUtility::mkdir($baseDirectory . '/foo');
     chmod($baseDirectory . '/foo', 1751);
     Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/foo/file', '42');
     chmod($baseDirectory . '/foo/file', 482);
     Utility\GeneralUtility::mkdir($baseDirectory . '/.bar');
     chmod($baseDirectory . '/.bar', 1751);
     // Use this if writeFileToTypo3tempDir is fixed to create hidden files in subdirectories
     // t3lib_div::writeFileToTypo3tempDir($baseDirectory . '/.bar/.file', '42');
     // t3lib_div::writeFileToTypo3tempDir($baseDirectory . '/.bar/..file2', '42');
     touch($baseDirectory . '/.bar/.file', '42');
     chmod($baseDirectory . '/.bar/.file', 482);
     touch($baseDirectory . '/.bar/..file2', '42');
     chmod($baseDirectory . '/.bar/..file2', 482);
     // Set target permissions and run method
     $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
     $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
     $fixPermissionsResult = Utility\GeneralUtility::fixPermissions($baseDirectory, TRUE);
     // Get actual permissions
     clearstatcache();
     $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
     $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
     $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
     $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
     $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
     $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
     $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
     // Clean up
     unlink($baseDirectory . '/file');
     unlink($baseDirectory . '/foo/file');
     unlink($baseDirectory . '/.bar/.file');
     unlink($baseDirectory . '/.bar/..file2');
     Utility\GeneralUtility::rmdir($baseDirectory . '/foo');
     Utility\GeneralUtility::rmdir($baseDirectory . '/.bar');
     Utility\GeneralUtility::rmdir($baseDirectory);
     // Test if everything was ok
     $this->assertTrue($fixPermissionsResult);
     $this->assertEquals($resultBaseDirectoryPermissions, '0770');
     $this->assertEquals($resultBaseFilePermissions, '0660');
     $this->assertEquals($resultFooDirectoryPermissions, '0770');
     $this->assertEquals($resultFooFilePermissions, '0660');
     $this->assertEquals($resultBarDirectoryPermissions, '0770');
     $this->assertEquals($resultBarFilePermissions, '0660');
     $this->assertEquals($resultBarFile2Permissions, '0660');
 }
Ejemplo n.º 24
0
 /**
  * Remove specified directory
  *
  * @param string $extDirPath
  * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
  * @return void
  */
 public function removeDirectory($extDirPath)
 {
     $res = GeneralUtility::rmdir($extDirPath, TRUE);
     if ($res === FALSE) {
         throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_remove_dir'), $this->getRelativePath($extDirPath)), 1337280415);
     }
 }
Ejemplo n.º 25
0
 /**
  * Remove specified directory
  *
  * @param string $extDirPath
  * @throws ExtensionManagerException
  * @return void
  */
 public function removeDirectory($extDirPath)
 {
     $extDirPath = GeneralUtility::fixWindowsFilePath($extDirPath);
     $extensionPathWithoutTrailingSlash = rtrim($extDirPath, '/');
     if (is_link($extensionPathWithoutTrailingSlash) && TYPO3_OS !== 'WIN') {
         $result = unlink($extensionPathWithoutTrailingSlash);
     } else {
         $result = GeneralUtility::rmdir($extDirPath, true);
     }
     if ($result === false) {
         throw new ExtensionManagerException(sprintf($this->languageService->getLL('fileHandling.couldNotRemoveDirectory'), $this->getRelativePath($extDirPath)), 1337280415);
     }
 }
 /**
  * @test
  */
 public function rmdirRemovesDeadLinkToFile()
 {
     if (TYPO3_OS === 'WIN') {
         $this->markTestSkipped('Test not available on Windows OS.');
     }
     $notExistingFile = PATH_site . 'typo3temp/' . $this->getUniqueId('notExists_');
     $symlinkName = PATH_site . 'typo3temp/' . $this->getUniqueId('link_');
     symlink($notExistingFile, $symlinkName);
     Utility\GeneralUtility::rmdir($symlinkName, TRUE);
     $this->assertFalse(is_link($symlinkName));
 }
Ejemplo n.º 27
0
 /**
  * Deletes the dummy folder specified in the first parameter $folderName.
  * The folder must be empty (no files or subfolders).
  *
  * @param string $folderName
  *        the path to the folder to delete relative to
  *        $this->uploadFolderPath, must not be empty
  *
  * @return void
  *
  * @throws \InvalidArgumentException
  * @throws Exception
  */
 public function deleteDummyFolder($folderName)
 {
     $absolutePathToFolder = $this->uploadFolderPath . $folderName;
     if (!is_dir($absolutePathToFolder)) {
         throw new \InvalidArgumentException('The folder "' . $absolutePathToFolder . '" which you are trying to delete does not exist.', 1334439343);
     }
     if (!isset($this->dummyFolders[$folderName])) {
         throw new \InvalidArgumentException('The folder "' . $absolutePathToFolder . '" which you are trying to delete was not created by this instance of ' . 'the testing framework.', 1334439387);
     }
     if (!GeneralUtility::rmdir($absolutePathToFolder)) {
         throw new Exception('The folder "' . $absolutePathToFolder . '" could not be deleted.', 1334439393);
     }
     unset($this->dummyFolders[$folderName]);
 }
Ejemplo n.º 28
0
 /**
  * Removes a folder from this storage.
  *
  * @param string $folderIdentifier
  * @param bool $deleteRecursively
  * @return bool
  * @throws Exception\FileOperationErrorException
  * @throws Exception\InvalidPathException
  */
 public function deleteFolder($folderIdentifier, $deleteRecursively = false)
 {
     $folderPath = $this->getAbsolutePath($folderIdentifier);
     $result = GeneralUtility::rmdir($folderPath, $deleteRecursively);
     if ($result === false) {
         throw new Exception\FileOperationErrorException('Deleting folder "' . $folderIdentifier . '" failed.', 1330119451);
     }
     return $result;
 }
 /**
  * @test
  */
 public function constructorCreatesLockDirectoryIfNotExisting()
 {
     GeneralUtility::rmdir(PATH_site . SimpleLockStrategy::FILE_LOCK_FOLDER, true);
     new SimpleLockStrategy('999999999');
     $this->assertTrue(is_dir(PATH_site . SimpleLockStrategy::FILE_LOCK_FOLDER));
 }
 /**
  * Removes the backup folder in typo3temp
  * @return void
  */
 protected function removeBackupFolder()
 {
     if (!empty($this->extensionBackupPath)) {
         GeneralUtility::rmdir($this->extensionBackupPath, true);
         $this->extensionBackupPath = '';
     }
 }