Prints the URL of a Puli path.

@param string $path A Puli path.
@param IO     $io   The I/O.
168371
private function printUrl($path, IO $io)
    {
        $path = Path::makeAbsolute($path, $this->currentPath);
        $io->writeLine($this->urlGenerator->generateUrl($path));
    }
294965
public function from_path(string $path, $type = 'page'): ?string
  {
    $parent = null;
    if ( $root = $this->opt->from_code($type, self::$option_root_id) ){
      $parts = explode('/', $path);
      $parent = $root;
      foreach ( $parts as $i => $p ){
        $is_not_last = $i < (\count($parts) - 1);
        if ( !empty($p) ){
          $prev_parent = $parent;
          // Adds a slash for each bit of the path except the last one
          $parent = $this->opt->from_code($p.($is_not_last ? '/' : ''), $prev_parent);
          // If not found looking for a subpermission
          if ( !$parent && $is_not_last ){
            $parent = $this->opt->from_code($p, $prev_parent);
          }
        }
      }
    }
    return $parent ?: null;
  }
1180266
function stream_open($path, $mode, $options, &$opened_path)
    {
        $path = $this->cleanUpPath($path);

        $this->fp = fopen($path, $mode, $options);

        return $this->fp !== false;
    }
190223
private function printTable(IO $io, array $matches)
    {
        $table = new Table(TableStyle::borderless());

        foreach ($matches as $path => $shortClass) {
            $table->addRow(array($shortClass, sprintf('<c1>%s</c1>', $path)));
        }

        $table->render($io);
    }
14732
public static RubyIO open(String path, String mode) {
    RubyIO io = null;
    try {
      io = new RubyIO(new File(path), Mode.fromString(mode));
    } catch (IOException e) {
      logger.log(Level.SEVERE, null, e);
      throw new RuntimeException(e);
    }
    return io;
  }
1332542
public static void writeFile(CompoundTag tag, String path) throws IOException {
        writeFile(tag, new File(path));
    }
830062
public function file($path, $type = 'debug')
    {
        $this->pushHandler(new StreamHandler($path, $this->getLevel($type)));
    }
1039750
public function createFile(ConsoleIo $io, $path, $contents)
    {
        return $this->verboseIfFileExists($io, $path) ? false : $io->createFile($path, $contents);
    }
997720
private static function write(IOInterface $io, string $message)
    {
        $msg = [
            '[Panthor]: ' . $message,
        ];

        $io->write($msg);
    }
825513
private function printBindingStateHeader(IO $io, $bindingState)
    {
        switch ($bindingState) {
            case BindingState::ENABLED:
                $io->writeLine('The following bindings are currently enabled:');
                $io->writeLine('');

                return;
            case BindingState::DISABLED:
                $io->writeLine('The following bindings are disabled:');
                $io->writeLine(' (use "puli bind --enable <uuid>" to enable)');
                $io->writeLine('');

                return;
            case BindingState::TYPE_NOT_FOUND:
                $io->writeLine('The types of the following bindings could not be found:');
                $io->writeLine(' (install or create their type definitions to enable)');
                $io->writeLine('');

                return;
            case BindingState::TYPE_NOT_ENABLED:
                $io->writeLine('The types of the following bindings are not enabled:');
                $io->writeLine(' (remove the duplicate type definitions to enable)');
                $io->writeLine('');

                return;
            case BindingState::INVALID:
                $io->writeLine('The following bindings have invalid parameters:');
                $io->writeLine(' (remove the binding and add again with correct parameters)');
                $io->writeLine('');

                return;
        }
    }
938698
public final void writeTo(String path) throws IOException {
        final int i = path.lastIndexOf(DOT);
        if (i < 0 || i + 1 == path.length())
            throw new IOException("Cannot find suffix in provided path: " + path);
        final String fmt = path.substring(i + 1);
        writeTo(fmt, path);
    }
643767
private static void addFolderToZip(String path, File folder, ZipOutputStream zos) throws IOException {
        String currentPath = StringUtils.isNotEmpty(path)? path + "/" + folder.getName(): folder.getName();

        for (File file : folder.listFiles()) {
            if (file.isDirectory()) {
                addFolderToZip(currentPath, file, zos);
            } else {
                addFileToZip(currentPath, file, zos);
            }
        }
    }
907199
public void redirect(String path) throws IOException
    {
        //response.setHeader("Location", path.charAt(0)=='/' ? path : "/"+path);
        response.sendRedirect(path.charAt(0)=='/' ? path : "/"+path);
        output.close();
    }
1007985
public static void setXwpfDocument(String path) throws IOException {
        InputStream is = new FileInputStream(path);
        xwpfDocument = new XWPFDocument(is);
        is.close();
    }
680504
public static OutputStream newOutputStream(String path) throws IOException
    {
        if (IOAdapter == null) return new FileOutputStream(path);
        return IOAdapter.create(path);
    }
188456
public function folderChmod(ConsoleIo $io, $path, $chmod = 0777)
    {
        if (!(new Folder())->chmod($path, $chmod, true)) {
            $io->error(__d('me_tools', 'Failed to set permissions on `{0}`', rtr($path)));

            return false;
        }

        $io->verbose(__d('me_tools', 'Setted permissions on `{0}`', rtr($path)));

        return true;
    }
1024720
public function handle(Args $args, IO $io)
    {
        $path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);

        $resource = $this->repo->get($path);
        $total = 0;

        $io->writeLine('<c1>'.$resource->getPath().'</c1>');

        $this->printTree($io, $resource, $total);

        $io->writeLine('');
        $io->writeLine($total.' resources');

        return 0;
    }