aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/Path.java
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2015-10-20 21:54:34 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-10-21 14:39:08 +0000
commitd8b6ff2dad1de2d98a407ecf67a34fe12e67d494 (patch)
tree030c5ebb89ca5835e76854ed51c0d2a75b04e4e3 /src/main/java/com/google/devtools/build/lib/vfs/Path.java
parent11ef8fc44821fb593a512eb5a3423013abbe39aa (diff)
Introduce Path#isSpecialFile, FileSystem#isSpecialFile, and FileStatus#isSpecialFile to help disambiguate between a regular file and a special file, since the file size of a special file cannot be trusted.
-- MOS_MIGRATED_REVID=105903622
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/Path.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/Path.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/Path.java b/src/main/java/com/google/devtools/build/lib/vfs/Path.java
index aac68ee8b0..c7c54712a3 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/Path.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/Path.java
@@ -533,6 +533,25 @@ public class Path implements Comparable<Path>, Serializable {
}
/**
+ * Returns true iff this path denotes an existing special file (e.g. fifo).
+ * Follows symbolic links.
+ */
+ public boolean isSpecialFile() {
+ return fileSystem.isSpecialFile(this, true);
+ }
+
+ /**
+ * Returns true iff this path denotes an existing special file (e.g. fifo).
+ *
+ * @param followSymlinks if {@link Symlinks#FOLLOW}, and this path denotes a
+ * symbolic link, the link is dereferenced until a path other than a
+ * symbolic link is found.
+ */
+ public boolean isSpecialFile(Symlinks followSymlinks) {
+ return fileSystem.isSpecialFile(this, followSymlinks.toBoolean());
+ }
+
+ /**
* Returns true iff this path denotes an existing symbolic link. Does not
* follow symbolic links.
*/
@@ -814,7 +833,7 @@ public class Path implements Comparable<Path>, Serializable {
* Returns the size in bytes of the file denoted by the current path,
* following symbolic links.
*
- * <p>The size of directory or special file is undefined.
+ * <p>The size of a directory or special file is undefined and should not be used.
*
* @throws FileNotFoundException if the file denoted by the current path does
* not exist