Ejemplo n.º 1
0
  private static void extractAndTransfer(
      Session session, String baseDir, ArchiveInput ai, String fileMode, Set<String> existingDirs)
      throws Throwable {

    ArchiveInput.Entry entry = null;
    try {
      while ((entry = ai.next()) != null) {
        String remotePath = PathUtil.join(baseDir, entry.name());
        if (entry.isDirectory()) {
          session.mkdir(remotePath, true, "0755");
          existingDirs.add(remotePath);
        } else {
          transfer(session, entry.stream(), entry.size(), remotePath, fileMode, existingDirs);
        }
      }
    } finally {
      ai.close();
    }
  }