From c1eecd5c78b7466ad11289bcf2e2394ff1ee2739 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 21 Sep 2003 16:14:09 +0000 Subject: [PATCH] don't delete sketch folders if they've been modified --- processing/app/PdeEditor.java | 53 +++++++++++++++++++++++++++++------ processing/todo.txt | 9 +++--- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index 0d4c09b41..292fd7df2 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -1461,6 +1461,24 @@ public class PdeEditor extends JPanel { //System.out.println("exiting doquit"); } + protected int calcFolderSize(File folder) { + int size = 0; + + //System.out.println("calcFolderSize " + folder); + String files[] = folder.list(); + for (int i = 0; i < files.length; i++) { + if (files[i].equals(".") || (files[i].equals("..")) || + files[i].equals(".DS_Store")) continue; + File fella = new File(folder, files[i]); + if (fella.isDirectory()) { + size += calcFolderSize(fella); + } else { + size += (int) fella.length(); + } + } + return size; + } + protected void doQuit2() { //System.out.println("doquit2"); //doStop(); @@ -1470,25 +1488,44 @@ public class PdeEditor extends JPanel { String userPath = base.sketchbookPath + File.separator + userName; File userFolder = new File(userPath); + //System.out.println("auto cleaning"); if (userFolder.exists()) { // huh? String entries[] = new File(userPath).list(); if (entries != null) { for (int j = 0; j < entries.length; j++) { + //System.out.println(entries[j] + " " + entries.length); + if ((entries[j].equals(".")) || (entries[j].equals(".."))) continue; - File preyDir = new File(userPath, entries[j]); - File prey = new File(preyDir, entries[j] + ".pde"); - if (prey.exists()) { - if (prey.length() == 0) { + + File prey = new File(userPath, entries[j]); + File pde = new File(prey, entries[j] + ".pde"); + + // make sure this is actually a sketch folder with a .pde, + // not a .DS_Store file or another random user folder + + if (pde.exists()) { + if (calcFolderSize(prey) == 0) { + //System.out.println("i want to remove " + prey); + removeDir(prey); + //} else { + //System.out.println("not removign because size is " + + // calcFolderSize(prey)); + } + } + + //File prey = new File(preyDir, entries[j] + ".pde"); + //if (prey.exists()) { + //if (prey.length() == 0) { // this is a candidate for deletion, but make sure // that the user hasn't added anything else to the folder //System.out.println("remove: " + prey); - removeDir(preyDir); - } - } else { + // removeDir(preyDir); + //} + //} else { //System.out.println(prey + " doesn't exist.. weird"); - } + //} } } } diff --git a/processing/todo.txt b/processing/todo.txt index 83c9be0c1..3e5ef65c0 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -101,6 +101,10 @@ X no time to ask for "save changes" before quit X PdeEditor, around line 910.. not blocking until input X read up on how to properly block for input in a java app X http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1061659700 +X do not delete sketch folder if empty sketch but non-empty data dir +X maybe needs to be a holding area for the current sketch +X this is how the read-only examples would be used +X http://proce55ing.net/discourse/yabb/YaBB.cgi?board=BugFixes;action=display;num=1064160655;start=0 fixes because of dmose parser @@ -200,11 +204,6 @@ X param(), online(), and status() functions HIGH (to be completed for 0060) - -_ do not delete sketch folder if empty sketch but non-empty data dir -_ maybe needs to be a holding area for the current sketch -_ this is how the read-only examples would be used -_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1062875454;start=0 _ QTJAVA path and CLASSPATH are weird if java not first installed _ or just get set improperly, reinstalling quicktime doesn't help _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1063012751;start=0