aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.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/AbstractFileSystem.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/AbstractFileSystem.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
index de67af85cf..1d0b4dc070 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
@@ -36,7 +36,7 @@ abstract class AbstractFileSystem extends FileSystem {
protected static final Profiler profiler = Profiler.instance();
@Override
- protected InputStream getInputStream(Path path) throws FileNotFoundException {
+ protected InputStream getInputStream(Path path) throws IOException {
// This loop is a workaround for an apparent bug in FileInputStrean.open, which delegates
// ultimately to JVM_Open in the Hotspot JVM. This call is not EINTR-safe, so we must do the
// retry here.
@@ -144,4 +144,28 @@ abstract class AbstractFileSystem extends FileSystem {
}
}
}
+
+ @Override
+ protected boolean isFile(Path path, boolean followSymlinks) {
+ FileStatus stat = statNullable(path, followSymlinks);
+ return stat != null ? stat.isFile() : false;
+ }
+
+ @Override
+ protected boolean isSpecialFile(Path path, boolean followSymlinks) {
+ FileStatus stat = statNullable(path, followSymlinks);
+ return stat != null ? stat.isSpecialFile() : false;
+ }
+
+ @Override
+ protected boolean isSymbolicLink(Path path) {
+ FileStatus stat = statNullable(path, false);
+ return stat != null ? stat.isSymbolicLink() : false;
+ }
+
+ @Override
+ protected boolean isDirectory(Path path, boolean followSymlinks) {
+ FileStatus stat = statNullable(path, followSymlinks);
+ return stat != null ? stat.isDirectory() : false;
+ }
}