classes/phing/util/FileUtils.php
public function resolveFile($file, $filename)
    {
        // remove this and use the static class constant File::separator
        // as soon as ZE2 is ready
        $fs = FileSystem::getFileSystem();

        $filename = str_replace(array('\\', '/'), $fs->getSeparator(), $filename);

        // deal with absolute files
        if (StringHelper::startsWith($fs->getSeparator(), $filename)
            || (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':')
        ) {
            return new PhingFile($this->normalize($filename));
        }

        if (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':') {
            return new PhingFile($this->normalize($filename));
        }

        $helpFile = new PhingFile($file->getAbsolutePath());

        $tok = strtok($filename, $fs->getSeparator());
        while ($tok !== false) {
            $part = $tok;
            if ($part === '..') {
                $parentFile = $helpFile->getParent();
                if ($parentFile === null) {
                    $msg = "The file or path you specified ($filename) is invalid relative to " . $file->getPath();
                    throw new IOException($msg);
                }
                $helpFile = new PhingFile($parentFile);
            } else {
                if ($part === '.') {
                    // Do nothing here
                } else {
                    $helpFile = new PhingFile($helpFile, $part);
                }
            }
            $tok = strtok($fs->getSeparator());
        }

        return new PhingFile($helpFile->getAbsolutePath());
    }
public function resolveFile($file, $filename)
    {
        // remove this and use the static class constant File::separator
        // as soon as ZE2 is ready
        $fs = FileSystem::getFileSystem();

        $filename = str_replace(array('\\', '/'), $fs->getSeparator(), $filename);

        // deal with absolute files
        if (StringHelper::startsWith($fs->getSeparator(), $filename)
            || (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':')
        ) {
            return new PhingFile($this->normalize($filename));
        }

        if (strlen($filename) >= 2 && Character::isLetter($filename{0}) && $filename{1} === ':') {
            return new PhingFile($this->normalize($filename));
        }

        $helpFile = new PhingFile($file->getAbsolutePath());

        $tok = strtok($filename, $fs->getSeparator());
        while ($tok !== false) {
            $part = $tok;
            if ($part === '..') {
                $parentFile = $helpFile->getParent();
                if ($parentFile === null) {
                    $msg = "The file or path you specified ($filename) is invalid relative to " . $file->getPath();
                    throw new IOException($msg);
                }
                $helpFile = new PhingFile($parentFile);
            } else {
                if ($part === '.') {
                    // Do nothing here
                } else {
                    $helpFile = new PhingFile($helpFile, $part);
                }
            }
            $tok = strtok($fs->getSeparator());
        }

        return new PhingFile($helpFile->getAbsolutePath());
    }
public function resolveFile ( $ file , $ filename ) { // remove this and use the static class constant File::separator // as soon as ZE2 is ready $ fs = FileSystem :: getFileSystem ( ) ; $ filename = str_replace ( array ( '\\' , '/' ) , $ fs -> getSeparator ( ) , $ filename ) ; // deal with absolute files if ( StringHelper :: startsWith ( $ fs -> getSeparator ( ) , $ filename ) || ( strlen ( $ filename ) >= 2 && Character :: isLetter ( $ filename { 0 } ) && $ filename { 1 } === ':' ) ) { return new PhingFile ( $ this -> normalize ( $ filename ) ) ; } if ( strlen ( $ filename ) >= 2 && Character :: isLetter ( $ filename { 0 } ) && $ filename { 1 } === ':' ) { return new PhingFile ( $ this -> normalize ( $ filename ) ) ; } $ helpFile = new PhingFile ( $ file -> getAbsolutePath ( ) ) ; $ tok = strtok ( $ filename , $ fs -> getSeparator ( ) ) ; while ( $ tok !== false ) { $ part = $ tok ; if ( $ part === '..' ) { $ parentFile = $ helpFile -> getParent ( ) ; if ( $ parentFile === null ) { $ msg = "The file or path you specified ($filename) is invalid relative to " . $ file -> getPath ( ) ; throw new IOException ( $ msg ) ; } $ helpFile = new PhingFile ( $ parentFile ) ; } else { if ( $ part === '.' ) { // Do nothing here } else { $ helpFile = new PhingFile ( $ helpFile , $ part ) ; } } $ tok = strtok ( $ fs -> getSeparator ( ) ) ; } return new PhingFile ( $ helpFile -> getAbsolutePath ( ) ) ; }
Interpret the filename as a file relative to the given file -
unless the filename already represents an absolute filename.

@param PhingFile $file the "reference" file for relative paths. This
instance must be an absolute file and must
not contain ./ or ../ sequences (same for \
instead of /).
@param string $filename a file name

@throws IOException

@return PhingFile A PhingFile object pointing to an absolute file that doesn't contain ./ or ../ sequences
and uses the correct separator for the current platform.
Interpret the filename as a file relative to the given file - unless the filename already represents an absolute filename .