aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java b/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java
index 41e45b1944..caad724f83 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java
@@ -554,6 +554,14 @@ public abstract class PathFragment implements Comparable<PathFragment>, Serializ
}
/**
+ * Returns the last segment in this path, or null if this PathFragment represents the root of the
+ * filesystem.
+ */
+ public PathFragment getLastSegment() {
+ return segments.length == 0 ? null : relativeTo(getParentDirectory());
+ }
+
+ /**
* Returns a new PathFragment formed by appending {@code newName} to the
* parent directory. Null is returned iff this method is called on a
* PathFragment with zero segments. If {@code newName} designates an absolute path,