fix rename and load_wrapper missing in Vfs class

This commit is contained in:
Ralf Becker 2016-07-21 11:17:01 +02:00
parent 14908a4172
commit 0c3c041dbb

View File

@ -771,6 +771,8 @@ class Vfs
*/ */
static function check_access($path, $check, $stat=null, $user=null) static function check_access($path, $check, $stat=null, $user=null)
{ {
static $vfs = null;
if (is_null($stat) && $user && $user != self::$user) if (is_null($stat) && $user && $user != self::$user)
{ {
static $path_user_stat = array(); static $path_user_stat = array();
@ -782,7 +784,7 @@ class Vfs
{ {
self::clearstatcache($path); self::clearstatcache($path);
$vfs = new Vfs\StreamWrapper(); if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
$path_user_stat[$path][$user] = $vfs->url_stat($path, 0); $path_user_stat[$path][$user] = $vfs->url_stat($path, 0);
self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again! self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again!
@ -2369,7 +2371,7 @@ class Vfs
{ {
if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link! if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link!
{ {
self::symlinkCache_remove($link); Vfs\StreamWrapper::symlinkCache_remove($link);
} }
return $ret; return $ret;
} }
@ -2458,6 +2460,35 @@ class Vfs
self::_call_on_backend('clearstatcache', array($path), true, 0); self::_call_on_backend('clearstatcache', array($path), true, 0);
Vfs\StreamWrapper::clearstatcache($path); Vfs\StreamWrapper::clearstatcache($path);
} }
/**
* This method is called in response to rename() calls on URL paths associated with the wrapper.
*
* It should attempt to rename the item specified by path_from to the specification given by path_to.
* In order for the appropriate error message to be returned, do not define this method if your wrapper does not support renaming.
*
* The regular filesystem stream-wrapper returns an error, if $url_from and $url_to are not either both files or both dirs!
*
* @param string $path_from
* @param string $path_to
* @return boolean TRUE on success or FALSE on failure
*/
function rename ( $path_from, $path_to )
{
$vfs = new Vfs\StreamWrapper();
return $vfs->rename($path_from, $path_to);
}
/**
* Load stream wrapper for a given schema
*
* @param string $scheme
* @return boolean
*/
static function load_wrapper($scheme)
{
return Vfs\StreamWrapper::load_wrapper($scheme);
}
} }
Vfs::init_static(); Vfs::init_static();