MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / unzipFile

Method unzipFile

java/src/org/openqa/selenium/io/Zip.java:139–157  ·  view source on GitHub ↗
(File output, InputStream zipStream, String name)

Source from the content-addressed store, hash-verified

137 }
138
139 public static void unzipFile(File output, InputStream zipStream, String name) throws IOException {
140 String canonicalDestinationDirPath = output.getCanonicalPath();
141 File toWrite = new File(output, name);
142 String canonicalDestinationFile = toWrite.getCanonicalPath();
143 if (!canonicalDestinationFile.startsWith(canonicalDestinationDirPath + File.separator)) {
144 throw new IOException("Entry is outside of the target dir: " + name);
145 }
146
147 if (!FileHandler.createDir(toWrite.getParentFile()))
148 throw new IOException("Cannot create parent directory for: " + name);
149
150 try (OutputStream out = new BufferedOutputStream(new FileOutputStream(toWrite), BUF_SIZE)) {
151 byte[] buffer = new byte[BUF_SIZE];
152 int read;
153 while ((read = zipStream.read(buffer)) != -1) {
154 out.write(buffer, 0, read);
155 }
156 }
157 }
158}

Callers 2

unzipMethod · 0.95
copyResourceMethod · 0.95

Calls 3

createDirMethod · 0.95
readMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected