diff options
author | 2017-02-07 09:42:36 +0000 | |
---|---|---|
committer | 2017-02-07 18:26:52 +0000 | |
commit | 8e0991cb19eadfcb651cd6987255d5f7c0a58e0a (patch) | |
tree | 6a27ef3ae3b4a0b0a44bd986a31ab36a0ea9d84f /src/main/java/com/google/devtools/build/lib/vfs | |
parent | 75392053de95cecf544d3f9b473a01288de6ee43 (diff) |
WindowsFileSystem.java: Fix createSymbolicLink when target is a relative path
Fixed https://github.com/bazelbuild/bazel/issues/2494
--
Change-Id: I2ca335fa5b3a7759f57085717128912f09363789
Reviewed-on: https://cr.bazel.build/8650
PiperOrigin-RevId: 146761747
MOS_MIGRATED_REVID=146761747
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java index 308e0dfc66..7a144f5c3e 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java @@ -335,7 +335,12 @@ public class WindowsFileSystem extends JavaIoFileSystem { if (targetFile.isDirectory()) { createDirectoryJunction(targetFile, file); } else { - Files.copy(targetFile.toPath(), file.toPath()); + if (targetFile.isAbsolute()) { + Files.copy(targetFile.toPath(), file.toPath()); + } else { + // When targetFile is a relative path to linkPath, resolve it to an absolute path first. + Files.copy(file.toPath().getParent().resolve(targetFile.toPath()), file.toPath()); + } } } catch (java.nio.file.FileAlreadyExistsException e) { throw new IOException(linkPath + ERR_FILE_EXISTS); |