/usr/share/php/PHP/Compat/Function/pathinfo.php is in php-compat 1.6.0a3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <?php
/**
* Replace function pathinfo() for PATHINFO_FILENAME support
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_Compat
* @author James Wade <hm2k@php.net>
* @copyright 2009 James Wade
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @version $CVS: 1.0 $
* @link http://php.net/function.pathinfo
* @since PHP 5.2.0
* @require PHP 4.0.0 (user_error)
*/
if (!defined('PATHINFO_FILENAME')) {
define('PATHINFO_FILENAME', 8);
}
/**
* Returns information about a file path
*
* @param string $path The path being checked.
* @param int $options See @link
*
* @return array
*/
function php_compat_pathinfo($path = false, $options = false)
{
// Sanity check
if (!is_scalar($path)) {
user_error('pathinfo() expects parameter 1 to be string, '
. gettype($path) . ' given', E_USER_WARNING);
return;
}
if (version_compare(PHP_VERSION, '5.2.0', 'ge')) {
return pathinfo($path, $options);
}
if ($options & PATHINFO_FILENAME) {
//bug #15688
if (strpos($path, '.') !== false) {
$filename = substr($path, 0, strrpos($path, '.'));
}
if ($options === PATHINFO_FILENAME) {
return $filename;
}
$pathinfo = pathinfo($path, $options);
$pathinfo['filename'] = $filename;
return $pathinfo;
}
return pathinfo($path, $options);
}
|