File tree 3 files changed +42
-26
lines changed
3 files changed +42
-26
lines changed Original file line number Diff line number Diff line change @@ -2604,12 +2604,7 @@ static public void copyDir(File sourceDir,
2604
2604
* Remove all files in a directory and the directory itself.
2605
2605
*/
2606
2606
static public void removeDir (File dir ) {
2607
- if (dir .exists ()) {
2608
- removeDescendants (dir );
2609
- if (!dir .delete ()) {
2610
- System .err .println (I18n .format (_ ("Could not delete {0}" ), dir ));
2611
- }
2612
- }
2607
+ BaseNoGui .removeDir (dir );
2613
2608
}
2614
2609
2615
2610
@@ -2620,24 +2615,7 @@ static public void removeDir(File dir) {
2620
2615
* (i.e. when cleaning temp files from lib/build)
2621
2616
*/
2622
2617
static public void removeDescendants (File dir ) {
2623
- if (!dir .exists ()) return ;
2624
-
2625
- String files [] = dir .list ();
2626
- for (int i = 0 ; i < files .length ; i ++) {
2627
- if (files [i ].equals ("." ) || files [i ].equals (".." )) continue ;
2628
- File dead = new File (dir , files [i ]);
2629
- if (!dead .isDirectory ()) {
2630
- if (!Preferences .getBoolean ("compiler.save_build_files" )) {
2631
- if (!dead .delete ()) {
2632
- // temporarily disabled
2633
- System .err .println (I18n .format (_ ("Could not delete {0}" ), dead ));
2634
- }
2635
- }
2636
- } else {
2637
- removeDir (dead );
2638
- //dead.delete();
2639
- }
2640
- }
2618
+ BaseNoGui .removeDescendants (dir );
2641
2619
}
2642
2620
2643
2621
Original file line number Diff line number Diff line change @@ -391,6 +391,45 @@ static public void prescanParameters(String args[]) {
391
391
PreferencesData .init (absoluteFile (preferencesFile ));
392
392
}
393
393
394
+ /**
395
+ * Recursively remove all files within a directory,
396
+ * used with removeDir(), or when the contents of a dir
397
+ * should be removed, but not the directory itself.
398
+ * (i.e. when cleaning temp files from lib/build)
399
+ */
400
+ static public void removeDescendants (File dir ) {
401
+ if (!dir .exists ()) return ;
402
+
403
+ String files [] = dir .list ();
404
+ for (int i = 0 ; i < files .length ; i ++) {
405
+ if (files [i ].equals ("." ) || files [i ].equals (".." )) continue ;
406
+ File dead = new File (dir , files [i ]);
407
+ if (!dead .isDirectory ()) {
408
+ if (!Preferences .getBoolean ("compiler.save_build_files" )) {
409
+ if (!dead .delete ()) {
410
+ // temporarily disabled
411
+ System .err .println (I18n .format (_ ("Could not delete {0}" ), dead ));
412
+ }
413
+ }
414
+ } else {
415
+ removeDir (dead );
416
+ //dead.delete();
417
+ }
418
+ }
419
+ }
420
+
421
+ /**
422
+ * Remove all files in a directory and the directory itself.
423
+ */
424
+ static public void removeDir (File dir ) {
425
+ if (dir .exists ()) {
426
+ removeDescendants (dir );
427
+ if (!dir .delete ()) {
428
+ System .err .println (I18n .format (_ ("Could not delete {0}" ), dir ));
429
+ }
430
+ }
431
+ }
432
+
394
433
/**
395
434
* Spew the contents of a String object out to a file.
396
435
*/
Original file line number Diff line number Diff line change 39
39
import java .util .SortedSet ;
40
40
import java .util .TreeSet ;
41
41
42
- import processing .app .Base ;
43
42
import processing .app .BaseNoGui ;
44
43
import processing .app .I18n ;
45
44
import processing .app .PreferencesData ;
@@ -201,7 +200,7 @@ protected void cleanup(boolean force, File tempBuildFolder) {
201
200
// the next time we start up, internal runs using Runner won't
202
201
// work because the build dir won't exist at startup, so the classloader
203
202
// will ignore the fact that that dir is in the CLASSPATH in run.sh
204
- Base .removeDescendants (tempBuildFolder );
203
+ BaseNoGui .removeDescendants (tempBuildFolder );
205
204
} else {
206
205
// delete only stale source files, from the previously
207
206
// compiled sketch. This allows multiple windows to be
You can’t perform that action at this time.
0 commit comments