(File newbie)
| 103 | |
| 104 | |
| 105 | public void fileSelected(File newbie) { |
| 106 | if (newbie != null) { |
| 107 | try { |
| 108 | // Force a .zip extension |
| 109 | // https://github.com/processing/processing/issues/2526 |
| 110 | if (!newbie.getName().toLowerCase().endsWith(".zip")) { |
| 111 | newbie = new File(newbie.getAbsolutePath() + ".zip"); |
| 112 | } |
| 113 | //System.out.println(newbie); |
| 114 | FileOutputStream zipOutputFile = new FileOutputStream(newbie); |
| 115 | ZipOutputStream zos = new ZipOutputStream(zipOutputFile); |
| 116 | |
| 117 | // recursively fill the zip file |
| 118 | File sketchFolder = editor.getSketch().getFolder(); |
| 119 | buildZip(sketchFolder, sketchFolder.getName(), zos); |
| 120 | |
| 121 | // close up the jar file |
| 122 | zos.flush(); |
| 123 | zos.close(); |
| 124 | |
| 125 | final String msg = |
| 126 | Language.interpolate("editor.status.archiver.create", |
| 127 | newbie.getName()); |
| 128 | editor.statusNotice(msg); |
| 129 | |
| 130 | } catch (IOException e) { |
| 131 | e.printStackTrace(); |
| 132 | } |
| 133 | } else { |
| 134 | editor.statusNotice(Language.text("editor.status.archiver.cancel")); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | |
| 139 | private void buildZip(File dir, String sofar, |
nothing calls this directly
no test coverage detected