Back to FileStorage class

Method _cleanPath

protected string
_cleanPath
(mixed $path, mixed $ds = DIRECTORY_SEPARATOR)
Function to strip additional / or \ in a path name
Parameters
  • string $path The path to clean
  • string $ds Directory separator (optional)
Returns
  • string The cleaned path
Since
  • 1.7.0
Class: FileStorage
Project: Joomla

Method _cleanPath - Source code

/**
 * Function to strip additional / or \ in a path name
 *
 * @param   string  $path  The path to clean
 * @param   string  $ds    Directory separator (optional)
 *
 * @return  string  The cleaned path
 *
 * @since   1.7.0
 */
protected function _cleanPath($path, $ds = DIRECTORY_SEPARATOR)
{
    $path = trim($path);
    if (empty($path)) {
        return $this->_root;
    }
    // Remove double slashes and backslashes and convert all slashes and backslashes to DIRECTORY_SEPARATOR
    $path = preg_replace('#[/\\\\]+#', $ds, $path);
    return $path;
}