function dirDelete($event) { $path = $event->getArgument('path'); $ftp =& zmgSafemodePlugin::getFTPClient(); //Translate the destination path for the FTP account $path = zmgFileHelper::cleanPath(str_replace(zmgEnv::getRootPath(), $ftp->getRoot(), $path), '/'); if (!$ftp->rmdir($path)) { // FTP connector throws an error return false; } return true; }
/** * Utility function to read the files in a directory * @param string The file system path * @param string A filter for the names * @param boolean Recurse search into sub-directories * @param boolean True if to prepend the full path to the file name */ function readDir($path, $filter = '.', $recurse = false, $fullpath = false) { $arr = array(); if (!@is_dir($path)) { return $arr; } $handle = opendir($path); while ($file = readdir($handle)) { $dir = zmgFileHelper::cleanPath($path . DS . $file, false); $isDir = is_dir($dir); if ($file != "." && $file != ".." && $file != ".svn") { if (preg_match("/{$filter}/", $file)) { if ($fullpath) { $arr[] = trim(zmgFileHelper::cleanPath($path . DS . $file, false)); } else { $arr[] = trim($file); } } if ($recurse && $isDir) { $arr2 = zmgFileHelper::readDir($dir, $filter, $recurse, $fullpath); $arr = array_merge($arr, $arr2); } } } closedir($handle); asort($arr); return $arr; }