Example #1
0
 /**
  * Renames/Moves this file to the specified file instance.
  *
  * @param File $dest File to rename/move to.
  * @return boolean true- success, false - failure
  */
 function renameTo(&$dest)
 {
     $this->_clearCache();
     // Already exists
     if ($dest->exists()) {
         return false;
     }
     if ($this->_events) {
         $this->_manager->dispatchEvent("onBeforeFileAction", array(RENAME_ACTION, &$this, &$dest));
     }
     if ($this->_absPath != $dest->_absPath) {
         $status = rename($this->_manager->toOSPath($this->_absPath), $this->_manager->toOSPath($dest->_absPath));
     }
     if ($status && $this->_events) {
         $this->_manager->dispatchEvent("onFileAction", array(RENAME_ACTION, &$this, &$dest));
     }
     $isFile = is_file($this->_manager->toOSPath($this->_absPath));
     // Chmod the file/directory
     if (($mask = $dest->_getConfigValue("filesystem.local." . ($isFile ? "file" : "directory") . "_mask", false)) !== false) {
         @chmod($this->_manager->toOSPath($dest->_absPath), intval($mask, 8));
     }
     // Chown the file/directory
     if (($owner = $dest->_getConfigValue("filesystem.local." . ($isFile ? "file" : "directory") . "_owner", false)) !== false) {
         $this->_chown($this->_manager->toOSPath($dest->_absPath), $owner);
     }
     return $status;
 }