static function cleanPath( $path, $toType = self::SEPARATOR_UNIX ) { $path = eZDir::convertSeparators( $path, $toType ); $separator = eZDir::separator( $toType ); if ( strpos( $path, $separator . $separator ) !== false ) { $path = preg_replace( "#$separator{2,}#", $separator, $path ); } $pathElements = explode( $separator, $path ); $newPathElements = array(); foreach ( $pathElements as $pathElement ) { if ( $pathElement === '.' ) continue; if ( $pathElement === '..' and count( $newPathElements ) > 0 ) array_pop( $newPathElements ); else $newPathElements[] = $pathElement; } if ( !isset( $newPathElements[0] ) ) $newPathElements[] = '.'; $path = implode( $separator, $newPathElements ); return $path; }