diff options
author | tomlu <tomlu@google.com> | 2017-12-21 08:59:51 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-21 09:01:56 -0800 |
commit | decca2bd97f6a7eb6b2ca0412ddc792d57f0f424 (patch) | |
tree | 759006fa2a07d44d7a30f25ff3e9fc89370a229c /src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java | |
parent | 8fb14d5871088e32078812f21ef24189729e38cc (diff) |
Add FileSystem#createDirectoryAndParents.
A native implementation of this (instead of using FileSystemUtils, which can only use public interfaces) should be more efficient and more easy to make correct.
In particular, it should allow removing FileSystemUtils#createDirectoriesAndParents, which has poor thread safety characteristics. The latter method has a lot of logic that forces certain unnatural atomicity guarantees on createDirectory, and it also has logic that is conditional on sub-string content of exception messages.
PiperOrigin-RevId: 179819623
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/JavaIoFileSystem.java | 6 |
1 files changed, 6 insertions, 0 deletions
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 dca8b95906..4477275f1f 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 @@ -258,6 +258,12 @@ public class JavaIoFileSystem extends AbstractFileSystemWithCustomStat { } } + @Override + public void createDirectoryAndParents(Path path) throws IOException { + java.nio.file.Path nioPath = getNioPath(path); + Files.createDirectories(nioPath); + } + private boolean linkExists(File file) { String shortName = file.getName(); File parentFile = file.getParentFile(); |