Skip to content

Commit dafc628

Browse files
committed
Fix symlinks being replaced with files on save
Fixes #5478
1 parent de9bd89 commit dafc628

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arduino-core/src/processing/app/BaseNoGui.java

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.*;
3434
import java.util.logging.Level;
3535
import java.util.logging.Logger;
36+
import java.nio.file.Files;
37+
import java.nio.file.Path;
3638

3739
import cc.arduino.packages.BoardPort;
3840

@@ -1058,6 +1060,10 @@ static public void saveFile(String str, File file) throws IOException {
10581060
File temp = File.createTempFile(file.getName(), null, file.getParentFile());
10591061
PApplet.saveStrings(temp, new String[] { str });
10601062
if (file.exists()) {
1063+
boolean isSymbolicLink = Files.isSymbolicLink(file.toPath());
1064+
if (isSymbolicLink) {
1065+
file = file.toPath().toRealPath().toFile().getAbsoluteFile();
1066+
}
10611067
boolean result = file.delete();
10621068
if (!result) {
10631069
throw new IOException(

0 commit comments

Comments
 (0)