(File dir, String sofar,
ZipOutputStream zos)
| 137 | |
| 138 | |
| 139 | private void buildZip(File dir, String sofar, |
| 140 | ZipOutputStream zos) throws IOException { |
| 141 | String files[] = dir.list(); |
| 142 | for (int i = 0; i < files.length; i++) { |
| 143 | if (files[i].equals(".") || //$NON-NLS-1$ |
| 144 | files[i].equals("..")) continue; //$NON-NLS-1$ |
| 145 | |
| 146 | File sub = new File(dir, files[i]); |
| 147 | String nowfar = (sofar == null) ? |
| 148 | files[i] : (sofar + "/" + files[i]); //$NON-NLS-1$ |
| 149 | |
| 150 | if (sub.isDirectory()) { |
| 151 | // directories are empty entries and have / at the end |
| 152 | ZipEntry entry = new ZipEntry(nowfar + "/"); //$NON-NLS-1$ |
| 153 | //System.out.println(entry); |
| 154 | zos.putNextEntry(entry); |
| 155 | zos.closeEntry(); |
| 156 | buildZip(sub, nowfar, zos); |
| 157 | |
| 158 | } else { |
| 159 | ZipEntry entry = new ZipEntry(nowfar); |
| 160 | entry.setTime(sub.lastModified()); |
| 161 | zos.putNextEntry(entry); |
| 162 | zos.write(Util.loadBytesRaw(sub)); |
| 163 | zos.closeEntry(); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
no test coverage detected