public function testDeleteRecursive() { $tmp = sys_get_temp_dir() . '/stash/'; $dirOne = $tmp . 'test/delete/recursive'; @mkdir($dirOne, 0770, true); touch($dirOne . '/test'); touch($dirOne . '/test2'); $dirTwo = $tmp . 'recursive/delete/test'; @mkdir($dirTwo, 0770, true); touch($dirTwo . '/test3'); touch($dirTwo . '/test4'); $this->assertTrue(Utilities::deleteRecursive($dirTwo . '/test3'), 'deleteRecursive returned true when removing single file.'); $this->assertFileNotExists($dirTwo . '/test3', 'deleteRecursive removed single file'); $this->assertTrue(Utilities::deleteRecursive($tmp), 'deleteRecursive returned true when removing directories.'); $this->assertFileNotExists($tmp, 'deleteRecursive cleared out the directory'); $this->assertFalse(Utilities::deleteRecursive($tmp), 'deleteRecursive returned false when passed nonexistant directory'); }
public static function tearDownAfterClass() { Utilities::deleteRecursive(Utilities::getBaseDirectory()); }
/** * This function clears the data from a key. If a key points to both a directory and a file, both are erased. If * passed null, the entire cache directory is removed. * * {@inheritdoc} */ public function clear($key = null) { $path = $this->makePath($key); if (is_file($path)) { $return = true; unlink($path); } $extension = $this->getEncoder()->getExtension(); if (strpos($path, $extension) !== false) { $path = substr($path, 0, -strlen($extension)); } if (is_dir($path)) { return Utilities::deleteRecursive($path, true); } return isset($return); }
/** * Clears data from database. If a key is defined only it and it's children are removed. If everything is set to be * cleared then the database itself is deleted off disk. * * @param null|string $key * @return bool */ public function clear($key = null) { // return true if the cache is already empty if (!($driver = $this->getDriver())) { return true; } if (!isset($key)) { unset($driver); $this->driver = null; $this->driver = false; \Stash\Utilities::deleteRecursive($this->path); } else { $driver->query("DELETE FROM cacheStore WHERE key LIKE '{$key}%'"); } return true; }
public function testCheckEmptyDirectory() { $tmp = sys_get_temp_dir() . '/stash/'; $dir2 = $tmp . 'emptytest/'; @mkdir($dir2, 0770, true); $this->assertTrue(Utilities::checkForEmptyDirectory($dir2), 'Returns true for empty directories'); $this->assertFalse(Utilities::checkForEmptyDirectory($tmp), 'Returns false for non-empty directories'); Utilities::deleteRecursive($tmp); }
/** * This function clears the data from a key. If a key points to both a directory and a file, both are erased. If * passed null, the entire cache directory is removed. * * {@inheritdoc} */ public function clear($key = null) { $path = $this->makePath($key); if (is_file($path)) { $return = true; unlink($path); } if (strpos($path, '.php') !== false) { $path = substr($path, 0, -4); } if (is_dir($path)) { return Utilities::deleteRecursive($path); } return isset($return); }