Пример #1
0
  /**
   * Function to do wildcard expansion (also known as ‘globbing’) on file paths.
   *
   * <p>Globbing is implemented by {@link FileScanner}
   *
   * @param paths character vector of patterns for relative or absolute filepaths. Missing values
   *     will be ignored.
   * @param markDirectories should matches to directories from patterns that do not already end in /
   *     or \ have a slash appended? May not be supported on all platforms.
   * @return
   */
  @Internal("Sys.glob")
  public static StringVector glob(
      @Current Context context, StringVector paths, boolean markDirectories) {

    List<String> matching = Lists.newArrayList();
    for (String path : paths) {
      if (path != null) {
        if (path.indexOf('*') == -1) {
          matching.add(path);
        } else {
          matching.addAll(FileScanner.scan(context, path, markDirectories));
        }
      }
    }
    return new StringArrayVector(matching);
  }