private function realPath($supplied_path, $dir_separator = DIRECTORY_SEPARATOR)
{
$current_path = $supplied_path;
if (!strlen($current_path)) {
return $dir_separator;
}
$win_drive = '';
// Windows OS path type detection
if (!strncasecmp(PHP_OS, 'win', 3)) {
$current_path = preg_replace('/[\\\\\\/]/', $dir_separator, $current_path);
if (preg_match('/([a-zA-Z]\\:)(.*)/', $current_path, $matches)) {
$win_drive = $matches[1];
$current_path = $matches[2];
} else {
$workingDir = getcwd();
$win_drive = substr($workingDir, 0, 2);
if ($current_path[0] !== $dir_separator[0]) {
$current_path = substr($workingDir, 3) . $dir_separator . $current_path;
}
}
} elseif ($current_path[0] !== $dir_separator) {
$current_path = getcwd() . $dir_separator . $current_path;
}
$paths = array();
foreach (explode($dir_separator, $current_path) as $path) {
if (strlen($path) && $path !== '.') {
if ($path == '..') {
array_pop($paths);
} else {
$paths[] = $path;
}
}
}
$realpath = $win_drive . $dir_separator . implode($dir_separator, $paths);
if ($current_path != $supplied_path) {
$this->addLog('Path "' . $supplied_path . '" resolved into "' . $realpath . '"', 'trace');
}
return $realpath;
}