dead code?

This commit is contained in:
rusefi 2020-07-02 16:14:19 -04:00
parent edc9158229
commit b71b9d274a
1 changed files with 0 additions and 48 deletions

View File

@ -32,54 +32,6 @@ public class FileUtil {
System.out.println("Unzip " + zipFileName + " to " + destPath + " worked!");
}
public static byte [] unzipFileContents(String zipFileName, String fileName) throws IOException {
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName));
ZipEntry zipEntry;
byte [] data = null;
while ((zipEntry = zis.getNextEntry()) != null) {
Path zippedName = Paths.get(zipEntry.getName()).normalize();
Path searchName = Paths.get(fileName).normalize();
if (zippedName.equals(searchName) && zipEntry.getSize() >= 0) {
int offset = 0;
byte [] tmpData = new byte[(int)zipEntry.getSize()];
int bytesLeft = tmpData.length, bytesRead;
while (bytesLeft > 0 && (bytesRead = zis.read(tmpData, offset, bytesLeft)) >= 0) {
offset += bytesRead;
bytesLeft -= bytesRead;
}
if (bytesLeft == 0) {
data = tmpData;
} else {
System.out.println("Unzip: error extracting file " + fileName);
}
break;
}
}
zis.closeEntry();
zis.close();
System.out.println("Unzip " + zipFileName + ": " + fileName + (data != null ? " extracted!" : " failed!"));
return data;
}
public static boolean zipAddFiles(String zipFileName, List<String> fileNames, String zipPath) throws IOException {
// requires Java7+
Map<String, String> env = new HashMap<>();
env.put("create", "true");
Path path = Paths.get(zipFileName);
URI uri = URI.create("jar:" + path.toUri());
FileSystem fs = FileSystems.newFileSystem(uri, env);
for (String fileName : fileNames) {
String fileNameInZip = zipPath + File.separator + fileName;
Path extFile = Paths.get(fileName);
Path zippedFile = fs.getPath(fileNameInZip);
Files.createDirectories(zippedFile.getParent());
//fs.provider().checkAccess(zippedFile, AccessMode.READ);
Files.copy(extFile, zippedFile, StandardCopyOption.REPLACE_EXISTING);
}
fs.close();
return true;
}
private static void unzipFile(byte[] buffer, ZipInputStream zis, File newFile) throws IOException {
System.out.println("Unzipping " + newFile);
FileOutputStream fos = new FileOutputStream(newFile);