diff options
author | 2018-01-12 10:26:38 -0800 | |
---|---|---|
committer | 2018-01-12 10:28:22 -0800 | |
commit | 775d3a9066cd674f158652ca3c6abf2ed6cd5549 (patch) | |
tree | efabc45656c700c772725064f45d93a572fa2e71 | |
parent | eec7250dccba5bf19b6c923b7213138c74187c20 (diff) |
Change packaging rules to operate on strings instead of path fragments.
The upcoming path refactor will normalize all path fragments upon creation. That is fine 99% of the time, but sometimes we want to disallow non-normalized paths on rule attributes. Even this isn't usually a problem since we can validate the string prior to putting it in a path fragment.
However, in the case of the packaging rule we do not know the rules of validation until the packaging rule is *consumed* by some other rule. Therefore, retain input as a string on these rules all the way through.
We don't really do a lot of path fragmenty stuff with these strings. The main drawback is losing a bit of type safety / readability.
SKIP_KOKORO
PiperOrigin-RevId: 181760613
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java | 8 |
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 6f6dfbf819..30a280292f 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 @@ -390,6 +390,10 @@ public abstract class PathFragment return true; } + public static boolean isNormalized(String path) { + return PathFragment.create(path).isNormalized(); + } + /** * Normalizes the path fragment: removes "." and ".." segments if possible * (if there are too many ".." segments, the resulting PathFragment will still @@ -636,6 +640,10 @@ public abstract class PathFragment */ public abstract boolean isAbsolute(); + public static boolean isAbsolute(String path) { + return PathFragment.create(path).isAbsolute(); + } + /** * Returns the segments of this path fragment. This array should not be * modified. |