Esempio n. 1
0
  @Nullable
  @RecursiveMethod
  private static PathParts splitFromRight(
      @NotNull Path left, @NotNull String right, @NotNull Predicate<Path> leftPredicate) {
    if (leftPredicate.apply(left)) return new PathParts(left, right);

    // Reached left end of a relative path
    if (!left.getPath().contains("/") && !left.getPath().contains("\\")) return null;

    String[] leftParts = splitAtLastSeparator(left.getPath());

    // Reached Unix root
    if (leftParts[0].isEmpty()) return null;

    // Reached Windows root
    if (leftParts[0].matches("[a-zA-Z]:")) return null;

    // Move by one path part to the left and recurse
    String newRight = Util.joinPath(leftParts[1], right);
    return splitFromRight(new Path(leftParts[0]), newRight, leftPredicate);
  }
Esempio n. 2
0
 @NotNull
 public Path createSubPath(@NotNull String pathPart) {
   return new Path(Util.joinPath(path, pathPart));
 }