allow perl regular expression as mime-type filter

This commit is contained in:
Ralf Becker 2015-01-19 16:09:16 +00:00
parent 94ea53a688
commit b6a83398a4

View File

@ -417,7 +417,7 @@ class egw_vfs extends vfs_stream_wrapper
* - name,path => pattern with *,? wildcards, eg. "*.php"
* - name_preg,path_preg => preg regular expresion, eg. "/(vfs|wrapper)/"
* - uid,user,gid,group,nouser,nogroup file belongs to user/group with given name or (numerical) id
* - mime => type[/subtype]
* - mime => type[/subtype] or perl regular expression starting with a "/" eg. "/^(image|video)\\//i"
* - empty,size => (+|-|)N
* - cmin/mmin => (+|-|)N file/dir create/modified in the last N minutes
* - ctime/mtime => (+|-|)N file/dir created/modified in the last N days
@ -666,6 +666,15 @@ class egw_vfs extends vfs_stream_wrapper
return; // wrong user or group
}
if (isset($options['mime']) && $options['mime'] != $stat['mime'])
{
if ($options['mime'][0] == '/') // perl regular expression given
{
if (!preg_match($options['mime'], $stat['mime']))
{
return; // wrong mime-type
}
}
else
{
list($type,$subtype) = explode('/',$options['mime']);
// no subtype (eg. 'image') --> check only the main type
@ -674,6 +683,7 @@ class egw_vfs extends vfs_stream_wrapper
return; // wrong mime-type
}
}
}
if (isset($options['size']) && !self::_check_num($stat['size'],$options['size']) ||
(isset($options['empty']) && !!$options['empty'] !== !$stat['size']))
{