mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-28 10:53:39 +01:00
Implement symlink for filesystem StreamWrapper with test
Whether it works or not depends on filesystem though.
This commit is contained in:
parent
e7f24461f8
commit
f7aef98666
@ -298,6 +298,36 @@ class StreamWrapper implements Vfs\StreamWrapperIface
|
||||
return $this->url_stat($this->opened_stream_url,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called for symlink()
|
||||
*
|
||||
* @param string $target
|
||||
* @param string $link
|
||||
* @return boolean true on success false on error
|
||||
*/
|
||||
public static function symlink($target,$link)
|
||||
{
|
||||
$_target = Vfs::resolve_url($target);
|
||||
$_link = Vfs::resolve_url($link);
|
||||
// Check target & link are both filesystem, otherwise it needs to be in Sqlfs
|
||||
$target_scheme = Vfs::parse_url($_target, PHP_URL_SCHEME);
|
||||
$link_scheme = Vfs::parse_url($_link, PHP_URL_SCHEME);
|
||||
if($target_scheme == static::SCHEME && $link_scheme == static::SCHEME)
|
||||
{
|
||||
$linked = symlink(
|
||||
Vfs::parse_url($_target,PHP_URL_PATH),
|
||||
Vfs::parse_url($_link, PHP_URL_PATH)
|
||||
);
|
||||
clearstatcache();
|
||||
return $linked && is_link($_link);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sqlfs = new Vfs\Sqlfs\StreamWrapper();
|
||||
return $sqlfs->symlink($target, $link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called in response to unlink() calls on URL paths associated with the wrapper.
|
||||
*
|
||||
|
@ -43,6 +43,12 @@ class StreamWrapperTest extends Vfs\StreamWrapperBase
|
||||
$this->markTestSkipped("Filesystem StreamWrapper does not support giving access to a file by changing group permissions");
|
||||
}
|
||||
|
||||
public function testSymlinkFromFolder($test_file = ''): void
|
||||
{
|
||||
// Pass a file inside the mountpoint. It doesn't need to exists
|
||||
parent::testSymlinkFromFolder(static::$mountpoint . '/test');
|
||||
}
|
||||
|
||||
protected function mount(): void
|
||||
{
|
||||
$this->mountFilesystem(static::$mountpoint);
|
||||
|
@ -354,8 +354,8 @@ abstract class StreamWrapperBase extends LoggedInTest
|
||||
}
|
||||
$ns = explode('\\', __NAMESPACE__);
|
||||
$test_base_dir = $test_file . '/'.array_pop($ns).'/'.$this->getName();
|
||||
$source_dir = $test_base_dir . "/link_test";
|
||||
$link_dir = $test_base_dir . "/link_target";
|
||||
$source_dir = $test_base_dir . "/link_target";
|
||||
$link_dir = $test_base_dir . "/im_a_symlink";
|
||||
|
||||
// Check if backend supports it
|
||||
$url = Vfs::resolve_url_symlinks($test_base_dir,false,false);
|
||||
|
Loading…
Reference in New Issue
Block a user