aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs
diff options
context:
space:
mode:
authorGravatar felly <felly@google.com>2018-06-06 19:31:23 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-06 19:32:38 -0700
commit89d85ea3c515cb288a388d89673e773f6806d7fa (patch)
tree2cff8b9d8f912f7a70f180be9310e7d8a6831bbb /src/main/java/com/google/devtools/build/lib/vfs
parentccaccb2b277a82f7264567563a02ab133a0f6e6f (diff)
Allow for Path and Root resolution when extracting action metadata.
RELNOTES: None PiperOrigin-RevId: 199572597
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/Root.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/Root.java b/src/main/java/com/google/devtools/build/lib/vfs/Root.java
index c7c78900f8..454e9b26a2 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/Root.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/Root.java
@@ -40,6 +40,12 @@ public abstract class Root implements Comparable<Root>, Serializable {
return fileSystem.getAbsoluteRoot();
}
+ public static Root toFileSystem(Root root, FileSystem fileSystem) {
+ return root.isAbsolute()
+ ? new AbsoluteRoot(fileSystem)
+ : new PathRoot(fileSystem.getPath(root.asPath().asFragment()));
+ }
+
/** Returns a path by concatenating the root and the root-relative path. */
public abstract Path getRelative(PathFragment rootRelativePath);