MCPcopy Index your code
hub / github.com/arduino/Arduino / buildZip

Method buildZip

app/src/processing/app/tools/Archiver.java:150–180  ·  view source on GitHub ↗
(File dir, String sofar,
                       ZipOutputStream zos)

Source from the content-addressed store, hash-verified

148
149
150 public void buildZip(File dir, String sofar,
151 ZipOutputStream zos) throws IOException {
152 String files[] = dir.list();
153 if (files == null) {
154 throw new IOException("Unable to list files from " + dir);
155 }
156 for (int i = 0; i < files.length; i++) {
157 if (files[i].equals(".") ||
158 files[i].equals("..")) continue;
159
160 File sub = new File(dir, files[i]);
161 String nowfar = (sofar == null) ?
162 files[i] : (sofar + "/" + files[i]);
163
164 if (sub.isDirectory()) {
165 // directories are empty entries and have / at the end
166 ZipEntry entry = new ZipEntry(nowfar + "/");
167 //System.out.println(entry);
168 zos.putNextEntry(entry);
169 zos.closeEntry();
170 buildZip(sub, nowfar, zos);
171
172 } else {
173 ZipEntry entry = new ZipEntry(nowfar);
174 entry.setTime(sub.lastModified());
175 zos.putNextEntry(entry);
176 zos.write(Base.loadBytesRaw(sub));
177 zos.closeEntry();
178 }
179 }
180 }
181}
182
183

Callers 1

runMethod · 0.95

Calls 4

loadBytesRawMethod · 0.95
listMethod · 0.80
equalsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected