Skip to content

Commit 33caa67

Browse files
authored
#1490: fix linking folders as junction with absolute path on Windows as fallback (#1494)
1 parent f2fc378 commit 33caa67

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ default void makeExecutable(Path path) {
407407

408408
/**
409409
* @param file the {@link Path} to the file to read.
410-
* @return the content of the specified file (in UTF-8 encoding), or null if the file doesn't exist
410+
* @return the content of the specified file (in UTF-8 encoding), or {@code null} if the file doesn't exist.
411411
* @see java.nio.file.Files#readString(Path)
412412
*/
413413
String readFileContent(Path file);

cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,14 @@ private Path adaptPath(Path target, Path link, boolean relative) {
495495
private void mklinkOnWindows(Path target, Path link, PathLinkType type) {
496496

497497
this.context.trace("Creating a Windows link at {} pointing to {}", link, target);
498-
ProcessResult result = this.context.newProcess().executable("cmd").addArgs("/c", "mklink", type.getMklinkOption(), link.toString(), target.toString())
498+
ProcessContext pc = this.context.newProcess().executable("cmd")
499+
.addArgs("/c", "mklink", type.getMklinkOption());
500+
if (type == PathLinkType.SYMBOLIC_LINK && Files.isDirectory(target)) {
501+
pc.addArg("/j");
502+
target = target.toAbsolutePath();
503+
}
504+
pc = pc.addArgs(link.toString(), target.toString());
505+
ProcessResult result = pc
499506
.run(ProcessMode.DEFAULT);
500507
result.failOnError();
501508
}

0 commit comments

Comments
 (0)