[gollem] change directory to ~foo or ~/foo
kevin mcgowan
clunis at umich.edu
Wed Mar 5 01:12:26 PST 2003
One of the features we'll need from gollem before we could deploy it on
our campus is the ability for users to enter strings like
"~foo/Public/html" or "~/Mail" as arguments to the "change directory"
command. I've attached a context diff against what I believe to be CVS
head of my take on how ( and where ) such ~ handling might work.
I know it is somewhat uncouth to join a list and then immediately
submit a patch, but I have to introduce myself somehow. :)
uncouthly,
Kevin
===================================================================
RCS file: /repository/horde/lib/VFS/file.php,v
retrieving revision 1.37
diff -c -r1.37 file.php
*** file.php 5 Mar 2003 03:33:12 -0000 1.37
--- file.php 5 Mar 2003 05:59:15 -0000
***************
*** 510,515 ****
--- 510,526 ----
}
}
if (!empty($path)) {
+ if (preg_match('|^~([^/]+)/?(.*)$|', $path, $matches)) {
+ $tmp = posix_getpwnam($matches[1]);
+ if ((isset($tmp['dir'])) &&
(strncmp($this->_params['vfsroot'],$tmp['dir'],strlen($this-
>_params['vfsroot'])))) {
+ $path = $tmp['dir'] . DIRECTORY_SEPARATOR .
$matches[2];
+ }
+ }
+
+ if (preg_match('|^~/?(.*)$|', $path, $matches)) {
+ $path = $this->_params['home'] . DIRECTORY_SEPARATOR .
$matches[1];
+ }
+
$path = str_replace('..', '', $path);
return $this->_params['vfsroot'] . DIRECTORY_SEPARATOR .
$path . $name;
} else {
More information about the gollem
mailing list