getStreamName()); } /** * Change file group. * * @param mixed $group Group name or number. * @return bool */ public function changeGroup($group) { return lchgrp($this->getStreamName(), $group); } /** * Change file owner. * * @param mixed $user User. * @return bool */ public function changeOwner($user) { return lchown($this->getStreamName(), $user); } /** * Get file permissions. * * @return int */ public function getPermissions() { return 41453; // i.e. lrwxr-xr-x } /** * Get the target of a symbolic link. * * @return \Hoa\File\Generic * @throws \Hoa\File\Exception */ public function getTarget() { $target = dirname($this->getStreamName()) . DS . $this->getTargetName(); $context = null !== $this->getStreamContext() ? $this->getStreamContext()->getCurrentId() : null; if (true === is_link($target)) { return new ReadWrite( $target, File::MODE_APPEND_READ_WRITE, $context ); } elseif (true === is_file($target)) { return new File\ReadWrite( $target, File::MODE_APPEND_READ_WRITE, $context ); } elseif (true === is_dir($target)) { return new File\Directory( $target, File::MODE_READ, $context ); } throw new File\Exception( 'Cannot find an appropriated object that matches with ' . 'path %s when defining it.', 1, $target ); } /** * Get the target name of a symbolic link. * * @return string */ public function getTargetName() { return readlink($this->getStreamName()); } /** * Create a link. * * @param string $name Link name. * @param string $target Target name. * @return bool */ public static function create($name, $target) { if (false != linkinfo($name)) { return true; } return symlink($target, $name); } } /** * Flex entity. */ Consistency::flexEntity('Hoa\File\Link\Link');