From 7d55a8f78cd32c0565b1804beb843c9b85f45c9c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 14 Jun 2011 07:38:07 +0000 Subject: [PATCH] fixing problem under windows: dirname("/something") === "\\", with which EGroupware VFS can NOT work, using now egw_vfs::dirname --- .../inc/class.sqlfs_stream_wrapper.inc.php | 25 ++++++++++--------- phpgwapi/inc/class.vfs_stream_wrapper.inc.php | 15 +++++------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php index 16ad0b5a7c..eec0d432e0 100644 --- a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php @@ -238,7 +238,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper $this->opened_stream = tmpfile(); } // create the hash-dirs, if they not yet exist - elseif(!file_exists($fs_dir=dirname(self::_fs_path($this->opened_fs_id)))) + elseif(!file_exists($fs_dir=egw_vfs::dirname(self::_fs_path($this->opened_fs_id)))) { $umaskbefore = umask(); if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); @@ -520,7 +520,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper $path = parse_url($url,PHP_URL_PATH); - if (!($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) || !egw_vfs::check_access(dirname($path),egw_vfs::WRITABLE)) + if (!($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) || !egw_vfs::check_access(egw_vfs::dirname($path),egw_vfs::WRITABLE)) { self::_remove_password($url); if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); @@ -570,7 +570,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper $path_from = parse_url($url_from,PHP_URL_PATH); $path_to = parse_url($url_to,PHP_URL_PATH); - $to_dir = dirname($path_to); + $to_dir = egw_vfs::dirname($path_to); $operation = self::url2operation($url_from); // we have to use array($class,'url_stat'), as $class.'::url_stat' requires PHP 5.2.3 and we currently only require 5.2+ @@ -640,7 +640,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper $maxdepth=10; $depth2propagate = (int)$depth + 1; if ($depth2propagate > $maxdepth) return is_dir($pathname); - is_dir(dirname($pathname)) || self::mkdir_recursive(dirname($pathname), $mode, $depth2propagate); + is_dir(egw_vfs::dirname($pathname)) || self::mkdir_recursive(egw_vfs::dirname($pathname), $mode, $depth2propagate); return is_dir($pathname) || @mkdir($pathname, $mode); } @@ -672,7 +672,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper } return false; } - $parent_path = dirname($path); + $parent_path = egw_vfs::dirname($path); if (($query = parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query; $parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET); @@ -729,7 +729,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); $path = parse_url($url,PHP_URL_PATH); - $parent = dirname($path); + $parent = egw_vfs::dirname($path); if (!($stat = self::url_stat($path,0)) || $stat['mime'] != self::DIR_MIME_TYPE || !egw_vfs::check_access($parent,egw_vfs::WRITABLE)) @@ -1034,6 +1034,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper { $eacl_access = self::check_extended_acl($path,egw_vfs::READABLE); // should be static::check_extended_acl, but no lsb! } + foreach($parts as $n => $name) { if ($n == 0) @@ -1200,7 +1201,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper { if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); - if (self::url_stat($link,0) || !($dir = dirname($link)) || + if (self::url_stat($link,0) || !($dir = egw_vfs::dirname($link)) || !egw_vfs::check_access($dir,egw_vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) { if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!stat('$link') || !is_writable('$dir'))"); @@ -1301,7 +1302,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper * * @param string $path string with path * @param int $rights=null rights to set, or null to delete the entry - * @param int/boolean $owner=null owner for whom to set the rights, null for the current user, or false to delete all rights for $path + * @param int|boolean $owner=null owner for whom to set the rights, null for the current user, or false to delete all rights for $path * @param int $fs_id=null fs_id to use, to not query it again (eg. because it's already deleted) * @return boolean true if acl is set/deleted, false on error */ @@ -1362,7 +1363,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper * Calls itself recursive, to get the parent directories * * @param string $path - * @return array/boolean array with array('path'=>$path,'owner'=>$owner,'rights'=>$rights) or false if $path not found + * @return array|boolean array with array('path'=>$path,'owner'=>$owner,'rights'=>$rights) or false if $path not found */ function get_eacl($path) { @@ -1397,8 +1398,8 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper * Searches the stat_cache first and then the db. * Calls itself recursive to to determine the path of the parent/directory * - * @param int/array $fs_ids integer fs_id or array of them - * @return string/array path or array or pathes indexed by fs_id + * @param int|array $fs_ids integer fs_id or array of them + * @return string|array path or array or pathes indexed by fs_id */ static function id2path($fs_ids) { @@ -1838,7 +1839,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper throw new egw_exception_assertion_failed(__METHOD__."(): fs_id=$fs_id ($fs_name, $fs_size bytes) content is NO resource! ".array2string($content)); } $filename = self::_fs_path($fs_id); - if (!file_exists($fs_dir=dirname($filename))) + if (!file_exists($fs_dir=egw_vfs::dirname($filename))) { self::mkdir_recursive($fs_dir,0700,true); } diff --git a/phpgwapi/inc/class.vfs_stream_wrapper.inc.php b/phpgwapi/inc/class.vfs_stream_wrapper.inc.php index a2326a2eca..b415293135 100644 --- a/phpgwapi/inc/class.vfs_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.vfs_stream_wrapper.inc.php @@ -201,10 +201,10 @@ class vfs_stream_wrapper implements iface_stream_wrapper trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING); return false; } - + /** * Returns mount url of a full url returned by resolve_url - * + * * @param string $fullurl full url returned by resolve_url * @return string|NULL mount url or null if not found */ @@ -653,7 +653,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper ($mime_attr = constant($class.'::STAT_RETURN_MIME_TYPE'))) { $stat = call_user_func(array($class,'url_stat'),parse_url($url,PHP_URL_PATH),0); - if ($stat[$mime_attr]) + if ($stat && $stat[$mime_attr]) { $mime = $stat[$mime_attr]; } @@ -703,7 +703,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper $basepath = parse_url($path,PHP_URL_PATH); foreach(self::$fstab as $mounted => $nul) { - if ((dirname($mounted) == $basepath || dirname($mounted).'/' == $basepath) && $mounted != '/') + if (((egw_vfs::dirname($mounted) == $basepath || egw_vfs::dirname($mounted).'/' == $basepath) && $mounted != '/')) { $this->extra_dirs[] = basename($mounted); } @@ -774,7 +774,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper } } // check if a failed url_stat was for a home dir, in that case silently create it - if (!$stat && $try_create_home && dirname(parse_url($path,PHP_URL_PATH)) == '/home' && + if (!$stat && $try_create_home && egw_vfs::dirname(parse_url($path,PHP_URL_PATH)) == '/home' && ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! { @@ -802,7 +802,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper // Todo: if we hide non readables, we should return false on url_stat for consitency (if dir is not writabel) // Problem: this does NOT stop (calles itself infinit recursive)! if (self::HIDE_UNREADABLES && !egw_vfs::check_access($path,egw_vfs::READABLE,$stat) && - !egw_vfs::check_access(dirname($path,egw_vfs::WRITABLE))) + !egw_vfs::check_access(egw_vfs::dirname($path,egw_vfs::WRITABLE))) { return false; } @@ -951,7 +951,8 @@ class vfs_stream_wrapper implements iface_stream_wrapper do { $file = readdir($this->opened_dir); } - while($file !== false && (is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // dont return mountpoints twice + while($file !== false && + (is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // do NOT return extra_dirs twice self::HIDE_UNREADABLES && !$this->opened_dir_writable && !egw_vfs::check_access(egw_vfs::concat($this->opened_dir_url,$file),egw_vfs::READABLE))); }