Skip to content

Commit

Permalink
Potential fix for ZIP methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Jun 28, 2021
1 parent 960b0d0 commit c1d4454
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions GalaxiAPI/global/src/net/ME1312/Galaxi/Library/Util.java
Expand Up @@ -316,18 +316,15 @@ public static void zip(File file, OutputStream zip) {
File dir = (file.isFile())?file.getParentFile():file;
byte[] buffer = new byte[4096];

try{
try {
ZipOutputStream zos = new ZipOutputStream(zip);

for(String next : zipsearch(file, file)){

ZipEntry ze= new ZipEntry(next.replace(File.separatorChar, '/'));
zos.putNextEntry(ze);

for (String next : zipsearch(file, file)) {
zos.putNextEntry(new ZipEntry(next.replace(File.separatorChar, '/')));
FileInputStream in = new FileInputStream(dir.getAbsolutePath() + File.separator + next);

int len;
while ((len = in.read(buffer)) > 0) {
while ((len = in.read(buffer)) != -1) {
zos.write(buffer, 0, len);
}

Expand All @@ -336,7 +333,7 @@ public static void zip(File file, OutputStream zip) {

zos.closeEntry();
zos.close();
} catch(IOException ex){
} catch(IOException ex) {
ex.printStackTrace();
}
}
Expand All @@ -363,15 +360,15 @@ public static void unzip(InputStream zip, File dir) {
}
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) > 0) {
while ((len = zis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}

fos.close();
}
zis.closeEntry();
zis.close();
} catch(IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}
Expand Down

0 comments on commit c1d4454

Please sign in to comment.