private function relativePath($from, $to, $ps = DIRECTORY_SEPARATOR)
    {
        $from = realpath($from);
        $to = realpath($to);

        $equalOffset = 0;
        $minLength = min(strlen($from), strlen($to));

        while ($equalOffset < $minLength && $from[$equalOffset] == $to[$equalOffset]) {
            $equalOffset++;
        }

        $backCount = $equalOffset == $minLength && strlen($from) < strlen($to) ?
            0 : substr_count($from, $ps, $equalOffset-1);

        return rtrim(str_repeat('..'.$ps, $backCount).ltrim(substr($to, $equalOffset), $ps), $ps);
    }