public function tearDown() { // Restore the is_apache global in-case it was messed with in the test global $is_apache; if (isset($this->is_apache)) { $is_apache = $this->is_apache; } if (file_exists($this->path->get_default_path())) { chmod($this->path->get_default_path(), 0755); } chmod(dirname($this->path->get_default_path()), 0755); // Remove all backup paths that exist foreach ($this->path->get_existing_paths() as $path) { rmdirtree($path); } // Remove our custom path rmdirtree($this->custom_path); // Reset the path internally $this->path->reset_path(); }
/** * Move backup files from an existing directory and the new * location * * @param string $path The path to move the backups from */ public function move_old_backups($from) { if (!is_readable($from)) { return; } if (!wp_is_writable(Path::get_path())) { return; } // Move any existing backups if ($handle = opendir($from)) { // Loop through the backup directory while (false !== ($file = readdir($handle))) { // Find all zips if ('zip' === pathinfo($file, PATHINFO_EXTENSION)) { // Try to move them if (!@rename(trailingslashit($from) . $file, trailingslashit(Path::get_path()) . $file)) { // If we can't move them then try to copy them copy(trailingslashit($from) . $file, trailingslashit(Path::get_path()) . $file); } } } closedir($handle); } // Delete the old directory if it's inside WP_CONTENT_DIR if (false !== strpos($from, WP_CONTENT_DIR) && $from !== Path::get_path()) { rmdirtree($from); } }
function tearDown() { rmdirtree($this->test_data); rmdirtree($this->test_data_symlink); }
function borrardirectorio($dirname) { if (is_dir($dirname)) { //Operate on dirs only $result = array(); if (substr($dirname, -1) != '/') { $dirname .= '/'; } //Append slash if necessary $handle = opendir($dirname); while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { //Ignore . and .. $path = $dirname . $file; if (is_dir($path)) { //Recurse if subdir, Delete if file $result = array_merge($result, rmdirtree($path)); } else { unlink($path); $result[] .= $path; } } } closedir($handle); rmdir($dirname); //Remove dir $result[] .= $dirname; return $result; //Return array of deleted items } else { return false; //Return false if attempting to operate on a file } }