aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-12-08 14:19:42 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-08 14:23:59 -0800
commitc2f6ae8f61b15c621323b62665b324ad21d59f32 (patch)
tree2496ec0d1f59cea23b7965a0547169e30bd3e14b /src/main/java/com
parentf35c8a0dfb74f7b0d7b292d5a23eb7ce10723954 (diff)
Thread filesystem through codebase.
RELNOTES: None PiperOrigin-RevId: 178426166
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java4
7 files changed, 26 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java b/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java
index 1a13b461fc..cfd07b336c 100644
--- a/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/unix/UnixFileSystem.java
@@ -349,7 +349,7 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
}
@Override
- protected void renameTo(Path sourcePath, Path targetPath) throws IOException {
+ public void renameTo(Path sourcePath, Path targetPath) throws IOException {
synchronized (sourcePath) {
NativePosixFiles.rename(sourcePath.toString(), targetPath.toString());
}
@@ -379,7 +379,7 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
}
@Override
- protected void setLastModifiedTime(Path path, long newTime) throws IOException {
+ public void setLastModifiedTime(Path path, long newTime) throws IOException {
synchronized (path) {
if (newTime == -1L) { // "now"
NativePosixFiles.utime(path.toString(), true, 0);
@@ -392,7 +392,7 @@ public class UnixFileSystem extends AbstractFileSystemWithCustomStat {
}
@Override
- protected byte[] getxattr(Path path, String name) throws IOException {
+ public byte[] getxattr(Path path, String name) throws IOException {
String pathName = path.toString();
long startTime = Profiler.nanoTimeMaybe();
try {
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java
index 6386b738b1..33fb154fdd 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java
@@ -284,10 +284,10 @@ public abstract class FileSystem {
protected abstract long getLastModifiedTime(Path path, boolean followSymlinks) throws IOException;
/**
- * Sets the last modification time of the file denoted by {@code path}. See
- * {@link Path#setLastModifiedTime} for specification.
+ * Sets the last modification time of the file denoted by {@code path}. See {@link
+ * Path#setLastModifiedTime} for specification.
*/
- protected abstract void setLastModifiedTime(Path path, long newTime) throws IOException;
+ public abstract void setLastModifiedTime(Path path, long newTime) throws IOException;
/**
* Returns value of the given extended attribute name or null if attribute
@@ -304,7 +304,7 @@ public abstract class FileSystem {
* system does not support extended attributes at all.
* @throws IOException if the call failed for any other reason.
*/
- protected byte[] getxattr(Path path, String name) throws IOException {
+ public byte[] getxattr(Path path, String name) throws IOException {
return null;
}
@@ -605,6 +605,11 @@ public abstract class FileSystem {
return readSymbolicLink(path);
}
+ /** Returns true iff this path denotes an existing file of any kind. Follows symbolic links. */
+ public boolean exists(Path path) {
+ return exists(path, true);
+ }
+
/**
* Returns true iff {@code path} denotes an existing file of any kind. See
* {@link Path#exists(Symlinks)} for specification.
@@ -751,11 +756,10 @@ public abstract class FileSystem {
protected abstract OutputStream getOutputStream(Path path, boolean append) throws IOException;
/**
- * Renames the file denoted by "sourceNode" to the location "targetNode".
- * See {@link Path#renameTo} for specification.
+ * Renames the file denoted by "sourceNode" to the location "targetNode". See {@link
+ * Path#renameTo} for specification.
*/
- protected abstract void renameTo(Path sourcePath, Path targetPath) throws IOException;
-
+ public abstract void renameTo(Path sourcePath, Path targetPath) throws IOException;
/**
* Create a new hard link file at "linkPath" for file at "originalPath".
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java
index e5ca35d3f4..e55877dd66 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java
@@ -308,7 +308,7 @@ public class JavaIoFileSystem extends AbstractFileSystemWithCustomStat {
}
@Override
- protected void renameTo(Path sourcePath, Path targetPath) throws IOException {
+ public void renameTo(Path sourcePath, Path targetPath) throws IOException {
synchronized (sourcePath) {
File sourceFile = getIoFile(sourcePath);
File targetFile = getIoFile(targetPath);
@@ -382,7 +382,7 @@ public class JavaIoFileSystem extends AbstractFileSystemWithCustomStat {
}
@Override
- protected void setLastModifiedTime(Path path, long newTime) throws IOException {
+ public void setLastModifiedTime(Path path, long newTime) throws IOException {
File file = getIoFile(path);
if (!file.setLastModified(newTime == -1L ? clock.currentTimeMillis() : newTime)) {
if (!file.exists()) {
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java
index 3f17588b8f..5369443c42 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystem.java
@@ -96,7 +96,7 @@ public abstract class ReadonlyFileSystem extends AbstractFileSystem {
}
@Override
- protected void renameTo(Path sourcePath, Path targetPath) throws IOException {
+ public void renameTo(Path sourcePath, Path targetPath) throws IOException {
throw modificationException();
}
@@ -106,7 +106,7 @@ public abstract class ReadonlyFileSystem extends AbstractFileSystem {
}
@Override
- protected void setLastModifiedTime(Path path, long newTime) throws IOException {
+ public void setLastModifiedTime(Path path, long newTime) throws IOException {
throw modificationException();
}
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java
index 1f34d99fb1..2c57bd26b6 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/ReadonlyFileSystemWithCustomStat.java
@@ -87,7 +87,7 @@ public abstract class ReadonlyFileSystemWithCustomStat extends AbstractFileSyste
}
@Override
- protected void renameTo(Path sourcePath, Path targetPath) throws IOException {
+ public void renameTo(Path sourcePath, Path targetPath) throws IOException {
throw modificationException();
}
@@ -97,7 +97,7 @@ public abstract class ReadonlyFileSystemWithCustomStat extends AbstractFileSyste
}
@Override
- protected void setLastModifiedTime(Path path, long newTime) throws IOException {
+ public void setLastModifiedTime(Path path, long newTime) throws IOException {
throw modificationException();
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
index 01ff5aa838..bdb3216223 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/UnionFileSystem.java
@@ -227,7 +227,7 @@ public class UnionFileSystem extends FileSystem {
}
@Override
- protected void setLastModifiedTime(Path path, long newTime) throws IOException {
+ public void setLastModifiedTime(Path path, long newTime) throws IOException {
path = internalResolveSymlink(path);
checkModifiable(path);
FileSystem delegate = getDelegate(path);
@@ -409,7 +409,7 @@ public class UnionFileSystem extends FileSystem {
}
@Override
- protected byte[] getxattr(Path path, String name) throws IOException {
+ public byte[] getxattr(Path path, String name) throws IOException {
path = internalResolveSymlink(path);
FileSystem delegate = getDelegate(path);
return delegate.getxattr(adjustPath(path, delegate), name);
@@ -431,7 +431,7 @@ public class UnionFileSystem extends FileSystem {
}
@Override
- protected void renameTo(Path sourcePath, Path targetPath) throws IOException {
+ public void renameTo(Path sourcePath, Path targetPath) throws IOException {
sourcePath = internalResolveSymlink(sourcePath);
FileSystem sourceDelegate = getDelegate(sourcePath);
if (!sourceDelegate.supportsModifications(sourcePath)) {
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java
index 7e4d6601bc..b439603bba 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java
@@ -702,7 +702,7 @@ public class InMemoryFileSystem extends FileSystem {
}
@Override
- protected void setLastModifiedTime(Path path, long newTime) throws IOException {
+ public void setLastModifiedTime(Path path, long newTime) throws IOException {
synchronized (this) {
InMemoryContentInfo status = scopeLimitedStat(path, true);
status.setLastModifiedTime(newTime == -1L ? clock.currentTimeMillis() : newTime);
@@ -751,7 +751,7 @@ public class InMemoryFileSystem extends FileSystem {
}
@Override
- protected void renameTo(Path sourcePath, Path targetPath)
+ public void renameTo(Path sourcePath, Path targetPath)
throws IOException {
if (sourcePath.equals(getRootDirectory())) {
throw Error.EACCES.exception(sourcePath);