PHPDaemon\FS\FileSystem::rename PHP Method

rename() public static method

Rename
public static rename ( string $path, string $newpath, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$newpath string New path
$cb callable Callback
$pri integer Priority
return resource | boolean
    public static function rename($path, $newpath, $cb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!self::$supported) {
            $r = rename($path, $newpath);
            if ($cb) {
                $cb($path, $newpath, $r);
            }
            return $r;
        }
        return eio_rename($path, $newpath, $pri, $cb, $path);
    }

Usage Example

Example #1
0
 /**
  * Moves an uploaded file to a new location
  * @param  string $filename The filename of the uploaded file
  * @param  string $dest The destination of the moved file
  * @return boolean           Success
  */
 public function moveUploadedFile($filename, $dest)
 {
     if (!$this->isUploadedFile($filename)) {
         return false;
     }
     return FileSystem::rename($filename, $dest);
 }