| @@ 453-481 (lines=29) @@ | ||
| 450 | ||
| 451 | class ar_ariadneContext implements ar_contextInterface { |
|
| 452 | ||
| 453 | public static function makePath( $cwd, $path ) { //FIXME: move this method to a better place |
|
| 454 | $result = '/'; |
|
| 455 | if ( $path[0] === '/' ) { |
|
| 456 | $path = substr( $path, 1); |
|
| 457 | } else { |
|
| 458 | $path = substr( $cwd, 1 ) . '/' . $path; |
|
| 459 | } |
|
| 460 | if ( $path ) { |
|
| 461 | $splitpath = explode( '/', $path ); |
|
| 462 | foreach ( $splitpath as $pathticle ) { |
|
| 463 | switch( $pathticle ) { |
|
| 464 | case ".." : |
|
| 465 | $result = dirname( $result ); |
|
| 466 | // if second char of $result is not set, then current result is the rootNode |
|
| 467 | if ( isset($result[1]) ) { |
|
| 468 | $result .= "/"; |
|
| 469 | } |
|
| 470 | $result[0] = "/"; // make sure that even under windows, slashes are always forward slashes. |
|
| 471 | break; |
|
| 472 | case "." : break; |
|
| 473 | case "" : break; |
|
| 474 | default: |
|
| 475 | $result .= $pathticle . '/'; |
|
| 476 | break; |
|
| 477 | } |
|
| 478 | } |
|
| 479 | } |
|
| 480 | return $result; |
|
| 481 | } |
|
| 482 | ||
| 483 | public static function getPath( $options = array() ) { |
|
| 484 | $me = self::getObject( $options ); |
|
| @@ 317-357 (lines=41) @@ | ||
| 314 | $this->close(); |
|
| 315 | } |
|
| 316 | ||
| 317 | public function make_path($curr_dir, $path) { |
|
| 318 | /********************************************************************** |
|
| 319 | This function creates an absolute path from the given starting path |
|
| 320 | ($curr_dir) and a relative (or absolute) path ($path). If $path starts |
|
| 321 | with a '/' $curr_dir is ignored. |
|
| 322 | $path must be a string of substrings seperated by '/'. each of these |
|
| 323 | substrings may consist of charachters and/or numbers. If a substring |
|
| 324 | is "..", it and the previuos substring will be removed. If a substring |
|
| 325 | is "." or "", it is removed. All other substrings are then concatenated |
|
| 326 | with a '/' between them and at the start and the end. This string is |
|
| 327 | then returned. |
|
| 328 | **********************************************************************/ |
|
| 329 | $this->error = ""; |
|
| 330 | $result = "/"; |
|
| 331 | if ($path[0] === "/") { |
|
| 332 | $path = substr($path, 1); |
|
| 333 | } else { |
|
| 334 | $path = substr($curr_dir, 1).'/'.$path; |
|
| 335 | } |
|
| 336 | if ($path) { |
|
| 337 | $splitpath=explode("/", $path); |
|
| 338 | foreach ($splitpath as $pathticle) { |
|
| 339 | switch($pathticle) { |
|
| 340 | case ".." : |
|
| 341 | $result = dirname($result); |
|
| 342 | // if second char of $result is not set, then current result is the rootNode |
|
| 343 | if (isset($result[1])) { |
|
| 344 | $result .= "/"; |
|
| 345 | } |
|
| 346 | $result[0] = "/"; // make sure that even under windows, slashes are always forward slashes. |
|
| 347 | break; |
|
| 348 | case "." : break; |
|
| 349 | case "" : break; |
|
| 350 | default: |
|
| 351 | $result .= $pathticle."/"; |
|
| 352 | break; |
|
| 353 | } |
|
| 354 | } |
|
| 355 | } |
|
| 356 | return $result; |
|
| 357 | } |
|
| 358 | ||
| 359 | public function save_properties($properties, $id) { |
|
| 360 | /******************************************************************** |
|