/** * This function deletes a directory or an array of directories from the * target directory. * * @param $directories The directory name or an array of directories names * relative to the target directory. * * @returns An array with the results. */ function deleteDirectory($directories) { if (!is_array($directories)) { $directories = array($directories); } $res = array(); foreach ($directories as $directory) { // The directory path $directory = YDPath::join($this->_target_dir, $directory); if (!is_dir($directory)) { $res[] = array('success' => false, 'action' => 'delete', 'type' => 'directory', 'item' => $directory, 'reason' => 'exist'); if ($this->_log) { YDLog::warning('Deleting directory: ' . $directory . ' - already exist'); } continue; } // The directory $d = new YDFSDirectory($directory); // Delete the directory if (!($success = $d->deleteDirectory($directory))) { if ($this->_log) { YDLog::error('Deleting directory: ' . $directory); } } else { if ($this->_log) { YDLog::info('Deleting directory: ' . $directory); } } $res[] = array('success' => $success, 'action' => 'delete', 'type' => 'directory', 'item' => $directory, 'reason' => 'failure'); } return $res; }