From 4561b75734aef2150467f8d3e77e89695ccab6bc Mon Sep 17 00:00:00 2001 From: benfry Date: Mon, 27 Sep 2004 04:38:20 +0000 Subject: [PATCH] implemented archiver tool --- processing/app/tools/Archiver.java | 42 +++++++++++++++++++++--------- processing/todo.txt | 3 ++- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/processing/app/tools/Archiver.java b/processing/app/tools/Archiver.java index e4ab1177b..9a44a1b85 100755 --- a/processing/app/tools/Archiver.java +++ b/processing/app/tools/Archiver.java @@ -24,11 +24,7 @@ //package processing.app.tools; // for 0071+ -//import java.awt.*; -//import java.awt.event.*; import java.io.*; -//import java.lang.reflect.*; -//import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; @@ -38,7 +34,7 @@ public class Archiver { PdeEditor editor; // someday these will be settable - boolean useDate = false; + boolean useDate = true; //false; int digits = 3; NumberFormat numberFormat; @@ -65,26 +61,40 @@ public class Archiver { //System.out.println("par " + parent); File newbie = null; + String namely = null; int index = 0; do { if (useDate) { String purty = dateFormat.format(new Date()); String stamp = purty + ((char) ('a' + index)); - newbie = new File(parent, name + "-" + stamp + ".zip"); + namely = name + "-" + stamp; + newbie = new File(parent, namely + ".zip"); } else { String diggie = numberFormat.format(index + 1); - newbie = new File(parent, name + "-" + diggie + ".zip"); + namely = name + "-" + diggie; + newbie = new File(parent, namely + ".zip"); } + index++; } while (newbie.exists()); - //System.out.println(newbie); - FileOutputStream zipOutputFile = new FileOutputStream(newbie); - ZipOutputStream zos = new ZipOutputStream(zipOutputFile); + try { + //System.out.println(newbie); + FileOutputStream zipOutputFile = new FileOutputStream(newbie); + ZipOutputStream zos = new ZipOutputStream(zipOutputFile); - // close up the jar file - zos.flush(); - zos.close(); + // recursively fill the zip file + buildZip(location, name, zos); + + // close up the jar file + zos.flush(); + zos.close(); + + editor.message("Created archive " + newbie.getName() + "."); + + } catch (IOException e) { + e.printStackTrace(); + } } @@ -100,10 +110,16 @@ public class Archiver { files[i] : (sofar + "/" + files[i]); if (sub.isDirectory()) { + // directories are empty entries and have / at the end + ZipEntry entry = new ZipEntry(nowfar + "/"); + //System.out.println(entry); + zos.putNextEntry(entry); + zos.closeEntry(); buildZip(sub, nowfar, zos); } else { ZipEntry entry = new ZipEntry(nowfar); + entry.setTime(sub.lastModified()); zos.putNextEntry(entry); zos.write(PdeBase.grabFile(sub)); zos.closeEntry(); diff --git a/processing/todo.txt b/processing/todo.txt index 232455c53..35499952e 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -138,7 +138,8 @@ X fix dist.sh for macosx X include some of the simong libraries X move libraries around in distribution to resemble sketchbook -_ add "archive" option since history is gone +040926 later +X add "archive" option since history is gone _ macosx - check to see if new linemetrics stuff is working better