frontend/modules/elfind/src/elFinderVolumeLocalFileSystem.class.php
/**
     * Return normalized path, this works the same as os.path.normpath() in Python
     *
     * @param  string $path path
     * @return string
     * @author Troex Nevelin
     **/
Return normalized path, this works the same as os.path.normpath() in Python
@param  string $path path
@return string
@author Troex Nevelin
Return normalized path this works the same as os . path . normpath () in Python @param string $path path @return string @author Troex Nevelin
protected function _normpath($path)
    {
        if (empty($path)) {
            return '.';
        }
        $changeSep = (DIRECTORY_SEPARATOR !== '/');
        if ($changeSep) {
            $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
        }
        if (strpos($path, '/') === 0) {
            $initial_slashes = true;
        } else {
            $initial_slashes = false;
        }
        if (($initial_slashes)
                && (strpos($path, '//') === 0)
                && (strpos($path, '///') === false)
        ) {
            $initial_slashes = 2;
        }
        $initial_slashes = (int)$initial_slashes;
        $comps = explode('/', $path);
        $new_comps = array();
        foreach ($comps as $comp) {
            if (in_array($comp, array('', '.'))) {
                continue;
            }
            if (($comp != '..')
                    || (!$initial_slashes && !$new_comps)
                    || ($new_comps && (end($new_comps) == '..'))
            ) {
                array_push($new_comps, $comp);
            } elseif ($new_comps) {
                array_pop($new_comps);
            }
        }
        $comps = $new_comps;
        $path = implode('/', $comps);
        if ($initial_slashes) {
            $path = str_repeat('/', $initial_slashes) . $path;
        }
        if ($changeSep) {
            $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
        }
        return $path ? $path : '.';
    }
protected function _normpath ( $ path ) { if ( empty ( $ path ) ) { return '.' ; } $ changeSep = ( DIRECTORY_SEPARATOR !== '/' ) ; if ( $ changeSep ) { $ path = str_replace ( DIRECTORY_SEPARATOR , '/' , $ path ) ; } if ( strpos ( $ path , '/' ) === 0 ) { $ initial_slashes = true ; } else { $ initial_slashes = false ; } if ( ( $ initial_slashes ) && ( strpos ( $ path , '//' ) === 0 ) && ( strpos ( $ path , '///' ) === false ) ) { $ initial_slashes = 2 ; } $ initial_slashes = ( int ) $ initial_slashes ; $ comps = explode ( '/' , $ path ) ; $ new_comps = array ( ) ; foreach ( $ comps as $ comp ) { if ( in_array ( $ comp , array ( '' , '.' ) ) ) { continue ; } if ( ( $ comp != '..' ) || ( ! $ initial_slashes && ! $ new_comps ) || ( $ new_comps && ( end ( $ new_comps ) == '..' ) ) ) { array_push ( $ new_comps , $ comp ) ; } elseif ( $ new_comps ) { array_pop ( $ new_comps ) ; } } $ comps = $ new_comps ; $ path = implode ( '/' , $ comps ) ; if ( $ initial_slashes ) { $ path = str_repeat ( '/' , $ initial_slashes ) . $ path ; } if ( $ changeSep ) { $ path = str_replace ( '/' , DIRECTORY_SEPARATOR , $ path ) ; } return $ path ? $ path : '.' ; }
Return normalized path, this works the same as os.path.normpath() in Python
 @param  string $path path
 @return string
 @author Troex Nevelin
Return normalized path this works the same as os . path . normpath () in Python @param string $path path @return string @author Troex Nevelin