From 0bcc625f31d5d431c2925bd58e77b8ea1acc14be Mon Sep 17 00:00:00 2001 From: lonnen Date: Thu, 25 Nov 2010 18:56:42 +0000 Subject: [PATCH] Fix for Issue 432. File saving now respects symlinks instead of overwriting them. --- app/src/processing/app/Base.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 5f6e2d8ee..8a901aebe 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2287,6 +2287,14 @@ public class Base { */ static public void saveFile(String str, File file) throws IOException { File temp = File.createTempFile(file.getName(), null, file.getParentFile()); + try{ + // fix from cjwant to prevent symlinks from being destroyed. + File canon = file.getCanonicalFile(); + file = canon; + } catch (IOException e) { + throw new IOException("Could not resolve canonical representation of " + + file.getAbsolutePath()); + } PApplet.saveStrings(temp, new String[] { str }); if (file.exists()) { boolean result = file.delete();