added clean temporary files method

This commit is contained in:
fros4943 2009-03-03 13:43:48 +00:00
parent 547eadceb3
commit 4fdb0c2f03

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ContikiMoteTypeDialog.java,v 1.54 2009/02/20 16:51:00 fros4943 Exp $ * $Id: ContikiMoteTypeDialog.java,v 1.55 2009/03/03 13:43:48 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote; package se.sics.cooja.contikimote;
@ -2190,6 +2190,18 @@ public class ContikiMoteTypeDialog extends JDialog {
testButton.setEnabled(settingsOK); testButton.setEnabled(settingsOK);
} }
public static void cleanTempFiles() {
File objectDir = ContikiMoteType.tempOutputDirectory;
if (objectDir.exists() && objectDir.isDirectory()) {
logger.info("Cleaning temporary files in: " + objectDir);
File[] objectFiles = objectDir.listFiles();
for (File objectFile : objectFiles) {
objectFile.delete();
}
objectDir.delete();
}
}
private class MoteTypeEventHandler private class MoteTypeEventHandler
implements implements
ActionListener, ActionListener,
@ -2227,16 +2239,7 @@ public class ContikiMoteTypeDialog extends JDialog {
myMoteType = null; myMoteType = null;
dispose(); dispose();
} else if (e.getActionCommand().equals("clean")) { } else if (e.getActionCommand().equals("clean")) {
// Delete any created intermediate files cleanTempFiles();
File objectDir = ContikiMoteType.tempOutputDirectory;
if (objectDir.exists() && objectDir.isDirectory()) {
File[] objectFiles = objectDir.listFiles();
for (File objectFile : objectFiles) {
objectFile.delete();
}
objectDir.delete();
}
} else if (e.getActionCommand().equals("create")) { } else if (e.getActionCommand().equals("create")) {
// Create mote type and set various data // Create mote type and set various data
try { try {