Exemple #1
0
  @Internal("file.copy")
  public static LogicalVector fileCopy(
      @Current Context context,
      StringVector fromFiles,
      String to,
      boolean overwrite,
      final boolean recursive)
      throws FileSystemException {
    LogicalArrayVector.Builder result = new LogicalArrayVector.Builder();
    FileObject toFile = context.resolveFile(to);
    for (String from : fromFiles) {
      try {
        toFile.copyFrom(
            context.resolveFile(from),
            new FileSelector() {

              @Override
              public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception {
                return true;
              }

              @Override
              public boolean includeFile(FileSelectInfo fileInfo) throws Exception {
                return recursive;
              }
            });
        result.add(true);
      } catch (FileSystemException e) {
        result.add(false);
      }
    }
    return result.build();
  }
Exemple #2
0
  @Internal("Sys.setenv")
  public static LogicalVector setEnvironment(
      @Current Context context, StringVector names, StringVector values) {

    Map<String, String> map = context.getSession().getSystemEnvironment();

    LogicalArrayVector.Builder result = new LogicalArrayVector.Builder();
    for (int i = 0; i != names.length(); ++i) {
      map.put(names.getElementAsString(i), values.getElementAsString(i));
      result.add(true);
    }
    return result.build();
  }
Exemple #3
0
  @Internal
  public static LogicalVector capabilities() {

    LogicalArrayVector.Builder result = new LogicalArrayVector.Builder();
    StringVector.Builder names = new StringVector.Builder();

    for (String capability : Capabilities.NAMES) {
      names.add(capability);
      result.add(false);
    }
    result.setAttribute(Symbols.NAMES, names.build());
    return result.build();
  }