File tree 1 file changed +12
-1
lines changed
arduino-core/src/processing/app
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -884,11 +884,22 @@ static public String sanitizeName(String origName) {
884
884
}
885
885
886
886
/**
887
- * Spew the contents of a String object out to a file.
887
+ * Save the content of a String into a file
888
+ * - Save the content into a temp file
889
+ * - Find the canonical path of the file (if it's a symlink, follow it)
890
+ * - Remove the original file
891
+ * - Move temp file to original path
892
+ * This ensures that the file is not getting truncated if the disk is full
888
893
*/
889
894
static public void saveFile (String str , File file ) throws IOException {
890
895
File temp = File .createTempFile (file .getName (), null , file .getParentFile ());
891
896
PApplet .saveStrings (temp , new String [] { str });
897
+
898
+ try {
899
+ file = file .getCanonicalFile ();
900
+ } catch (IOException e ) {
901
+ }
902
+
892
903
if (file .exists ()) {
893
904
boolean result = file .delete ();
894
905
if (!result ) {
You can’t perform that action at this time.
0 commit comments