function resolveFile(PhingFile $f) { $path = $f->getPath(); $pl = (int) $f->getPrefixLength(); if ($pl === 2 && $path[0] === $this->slash) { return path; // UNC } if ($pl === 3) { return $path; // Absolute local } if ($pl === 0) { return (string) ($this->_getUserPath() . $this->slashify($path)); //Completely relative } if ($pl === 1) { // Drive-relative $up = (string) $this->_getUserPath(); $ud = (string) $this->_getDrive($up); if ($ud !== null) { return (string) $ud . $path; } return (string) $up . $path; //User dir is a UNC path } if ($pl === 2) { // Directory-relative $up = (string) $this->_getUserPath(); $ud = (string) $this->_getDrive($up); if ($ud !== null && StringHelper::startsWith($ud, $path)) { return (string) ($up . $this->slashify(substr($path, 2))); } $drive = (string) $path[0]; $dir = (string) $this->_getDriveDirectory($drive); $np = (string) ""; if ($dir !== null) { /* When resolving a directory-relative path that refers to a drive other than the current drive, insist that the caller have read permission on the result */ $p = (string) $drive . (':' . $dir . $this->slashify(substr($path, 2))); if (!$this->checkAccess($p, false)) { // FIXME // throw security error die("Can't resolve path {$p}"); } return $p; } return (string) $drive . ':' . $this->slashify(substr($path, 2)); //fake it } throw new Exception("Unresolvable path: " . $path); }
function isAbsolute(PhingFile $f) { return $f->getPrefixLength() !== 0; }