diff --git a/processing/app/PdeCompiler.java b/processing/app/PdeCompiler.java index 17857db76..01dffb544 100644 --- a/processing/app/PdeCompiler.java +++ b/processing/app/PdeCompiler.java @@ -288,7 +288,7 @@ public class PdeCompiler implements PdeMessageConsumer { * Return the path for a folder, with appended paths to * any .jar or .zip files inside that folder. */ - static protected String includeFolder(File folder) { + static public String includeFolder(File folder) { if (folder == null) return ""; StringBuffer abuffer = new StringBuffer(); @@ -396,4 +396,105 @@ public class PdeCompiler implements PdeMessageConsumer { } return importCount; } + + + /// + + + // goes through a colon (or semicolon on windows) separated list + // of all the paths inside the 'code' folder + + static public void magicExports(String path, ZipOutputStream zos) + throws IOException { + String pieces[] = + BApplet.splitStrings(path, File.pathSeparatorChar); + + for (int i = 0; i < pieces.length; i++) { + if (pieces[i].length() == 0) continue; + //System.out.println("checking piece " + pieces[i]); + + // is it a jar file or directory? + if (pieces[i].toLowerCase().endsWith(".jar") || + pieces[i].toLowerCase().endsWith(".zip")) { + try { + ZipFile file = new ZipFile(pieces[i]); + Enumeration entries = file.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + if (entry.isDirectory()) { + String name = entry.getName(); + if (name.equals("META-INF/")) continue; + // actually 'continue's for all dir entries + + } else { + //zos.putNextEntry(entry); + ZipEntry entree = new ZipEntry(entry.getName()); + zos.putNextEntry(entree); + byte buffer[] = new byte[(int) entry.getSize()]; + InputStream is = file.getInputStream(entry); + //DataInputStream is = + //new DataInputStream(file.getInputStream(entry)); + //is.readFully(buffer); + //System.out.println(buffer.length); + //System.out.println(count + " " + buffer.length); + + int offset = 0; + int remaining = buffer.length; + while (remaining > 0) { + int count = is.read(buffer, offset, remaining); + offset += count; + remaining -= count; + } + + zos.write(buffer); + zos.flush(); + zos.closeEntry(); + } + } + } catch (IOException e) { + System.err.println("Error in file " + pieces[i]); + } + } else { // not a .jar or .zip, prolly a directory + File dir = new File(pieces[i]); + // but must be a dir, since it's one of several paths + // just need to check if it exists + if (dir.exists()) { + magicExportsRecursive(dir, null, zos); + } + } + } + } + + + static public void magicExportsRecursive(File dir, String sofar, + ZipOutputStream zos) + throws IOException { + + String files[] = dir.list(); + for (int i = 0; i < files.length; i++) { + //if (files[i].equals(".") || files[i].equals("..")) continue; + // ignore . .. and .DS_Store + if (files[i].charAt(0) == '.') continue; + + File sub = new File(dir, files[i]); + String nowfar = (sofar == null) ? + files[i] : (sofar + "/" + files[i]); + + if (sub.isDirectory()) { + magicExportsRecursive(sub, nowfar, zos); + + } else { + // don't add .jar and .zip files, since they only work + // inside the root, and they're unpacked + if (!files[i].toLowerCase().endsWith(".jar") && + !files[i].toLowerCase().endsWith(".zip") && + files[i].charAt(0) != '.') { + ZipEntry entry = new ZipEntry(nowfar); + zos.putNextEntry(entry); + zos.write(PdeEditor.grabFile(sub)); + zos.closeEntry(); + } + } + } + } } diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index cb65f5710..181d1a70e 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -1514,6 +1514,12 @@ public class PdeEditor extends JPanel { ZipOutputStream zos = new ZipOutputStream(zipOutputFile); ZipEntry entry; + File codeFolder = new File(sketchDir, "code"); + if (codeFolder.exists()) { + String includes = PdeCompiler.includeFolder(codeFolder); + PdeCompiler.magicExports(includes, zos); + } + // add standard .class files to the jar // these are the bagel classes found in export // they are a jdk11-only version of bagel @@ -1533,9 +1539,11 @@ public class PdeEditor extends JPanel { if ((dataDir != null) && (dataDir.exists())) { String datafiles[] = dataDir.list(); for (int i = 0; i < datafiles.length; i++) { - if (datafiles[i].equals(".") || datafiles[i].equals("..")) { - continue; - } + // don't export hidden files, this handles, . .. .DS_Store + if (datafiles[i].charAt(0) == '.') continue; + //if (datafiles[i].equals(".") || datafiles[i].equals("..")) { + //continue; + //} entry = new ZipEntry(datafiles[i]); zos.putNextEntry(entry); zos.write(grabFile(new File(dataDir, datafiles[i]))); diff --git a/processing/todo.txt b/processing/todo.txt index 42a396fcb..f9967d1f9 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -45,16 +45,18 @@ X http://docs.info.apple.com/article.html?artnum=93414&sessionID=anonymous%7C2 X "Type quicktime.std.stdQTConstants was not found" X http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1066358763 X http://docs.info.apple.com/article.html?artnum=120255 +X ignore dotfiles on export, both from code and data folder +X no more .DS_Store or other similar files +X included code is not packaged in the outgoing jar file on export +X http://proce55ing.net/discourse/yabb/YaBB.cgi?board=BugFixes;action=display;num=1066586882;start=0 _ new html code for eolas patent case _ move html to external file in the lib folder -_ included code is not packaged in the outgoing jar file on export -_ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1066008067;start=0 - ................ + // Rect is not getting it's stroke color set void setup() {