/** * Action event handler. * * @param int $action Action ID. * @param File $file1 File object 1. * @param File $file2 File object 2. */ function handleFileAction($action, $file1, $file2) { switch ($action) { case DELETE_ACTION: $this->_logMsg("Deleted file: " . $file1->getAbsolutePath()); break; case ADD_ACTION: $this->_logMsg("Added file: " . $file1->getAbsolutePath()); break; case UPDATE_ACTION: $this->_logMsg("Updated file: " . $file1->getAbsolutePath()); break; case RENAME_ACTION: $this->_logMsg("Renamed file: " . $file1->getAbsolutePath() . " to " . $file2->getAbsolutePath()); break; case COPY_ACTION: $this->_logMsg("Copied file: " . $file1->getAbsolutePath() . " to " . $file2->getAbsolutePath()); break; case MKDIR_ACTION: $this->_logMsg("Created directory: " . $file1->getAbsolutePath()); break; case RMDIR_ACTION: $this->_logMsg("Removed directory: " . $file1->getAbsolutePath()); break; default: $this->_logMsg("Unknown action: " . $action . "," . $file1->getAbsolutePath() . "," . $file1->getAbsolutePath()); } }
/** * Handles a file instance while looping an tree of directories. * * @param File $file File object reference * @param int $level Current level of tree parse * @return int State of what to do next can be CONTINUE, ABORT or ABORTFOLDER. */ function handle($file, $level) { $toPath = $this->_destFile->getAbsolutePath(); $toPath .= substr($file->getAbsolutePath(), strlen($this->_fromFile->getAbsolutePath())); $toFile = $this->_manager->getFile($toPath); // Do action if ($file->isDirectory()) { $toFile->mkdir(); } else { $file->copyTo($toFile); } return $this->CONTINUE; }
/** * returns the contents of a directory in an array */ public function lister(File $f, $filter = null) { $dir = @opendir($f->getAbsolutePath()->toNative()); if (!$dir) { throw new Exception("Can't open directory " . $f->toString()); } $vv = array(); while (($file = @readdir($dir)) !== false) { if ($file == "." || $file == "..") { continue; } $vv[] = (string) $file; } @closedir($dir); return $vv; }
/** * Handles a file instance while looping an tree of directories. * * @param File $file File object reference * @param int $level Current level of tree parse * @return int State of what to do next can be CONTINUE, ABORT or ABORTFOLDER. */ function handle($file, $level) { $toPath = $this->_destFile->getAbsolutePath(); $toPath .= substr($file->getAbsolutePath(), strlen($this->_fromFile->getAbsolutePath())); $toFile = new LocalFileImpl($this->_fileFactory, $toPath); //echo $file->getAbsolutePath() . "->" . $toPath . "<br />"; // Do action if ($file->isDirectory()) { $toFile->mkdir(); } else { $file->copyTo($toFile); } return $this->CONTINUE; }
/** * Whether file can be deleted. * @param File $f * @return boolean */ public function canDelete(File $f) { @clearstatcache(); $dir = dirname($f->getAbsolutePath()->toNative()); return (bool) @is_writable($dir); }