Fix for Issue 432. File saving now respects symlinks instead of overwriting them.

This commit is contained in:
lonnen
2010-11-25 18:56:42 +00:00
parent a0d9a606c0
commit 0bcc625f31

View File

@@ -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();