Пример #1
0
  @Override
  public void download(String remote, Path local, Collection<Option> options) throws IOException {
    local = ValidateUtils.checkNotNull(local, "Invalid argument local: %s", local);
    remote = ValidateUtils.checkNotNullAndNotEmpty(remote, "Invalid argument remote: %s", remote);

    LinkOption[] opts = IoUtils.getLinkOptions(false);
    if (Files.isDirectory(local, opts)) {
      options = addTargetIsDirectory(options);
    }

    if (options.contains(Option.TargetIsDirectory)) {
      Boolean status = IoUtils.checkFileExists(local, opts);
      if (status == null) {
        throw new SshException("Target directory " + local.toString() + " is probaly inaccesible");
      }

      if (!status.booleanValue()) {
        throw new SshException("Target directory " + local.toString() + " does not exist");
      }

      if (!Files.isDirectory(local, opts)) {
        throw new SshException("Target directory " + local.toString() + " is not a directory");
      }
    }

    download(remote, local.getFileSystem(), local, options);
  }