Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Commit b6a7308

Browse files
author
Explv
committed
Remove usage of Zip4J as this causes issues with permissions on Unix systems
1 parent 3b35a8e commit b6a7308

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
<artifactId>json-simple</artifactId>
2626
<version>1.1.1</version>
2727
</dependency>
28-
<dependency>
29-
<groupId>net.lingala.zip4j</groupId>
30-
<artifactId>zip4j</artifactId>
31-
<version>2.6.1</version>
32-
</dependency>
3328
<dependency>
3429
<groupId>org.osbot</groupId>
3530
<artifactId>osbot</artifactId>

resources-archive.zip

0 Bytes
Binary file not shown.

src/main/java/script/AIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@ScriptManifest(author = "Explv", name = "Explv's AIO " + AIO.VERSION, info = "AIO", version = 0, logo = "http://i.imgur.com/58Zz0fb.png")
2929
public class AIO extends Script {
3030

31-
public static final String VERSION = "v3.2.1";
31+
public static final String VERSION = "v3.2.2";
3232

3333
private Gui gui;
3434
private Paint paint;

src/main/java/util/file_managers/ResourceManager.java

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package util.file_managers;
22

3-
import net.lingala.zip4j.ZipFile;
4-
53
import java.io.*;
64
import java.net.URL;
75
import java.nio.channels.Channels;
86
import java.nio.channels.ReadableByteChannel;
9-
import java.nio.file.Files;
10-
import java.nio.file.Path;
11-
import java.nio.file.Paths;
12-
import java.nio.file.StandardCopyOption;
7+
import java.nio.file.*;
8+
import java.util.Enumeration;
9+
import java.util.zip.ZipEntry;
10+
import java.util.zip.ZipFile;
1311

1412
public class ResourceManager {
1513

@@ -91,8 +89,7 @@ private static void downloadResourcesFromGitHubToDataDirectory() {
9189

9290
System.out.println(String.format("Extracting file: %s, to: %s", outputFile.getAbsolutePath(), DIRECTORY));
9391

94-
ZipFile zipFile = new ZipFile(outputFile);
95-
zipFile.extractAll(DIRECTORY);
92+
unzipArchive(outputFile, new File(DIRECTORY));
9693

9794
outputFile.delete();
9895
} catch (IOException e) {
@@ -127,4 +124,45 @@ private static synchronized boolean saveFileToDataDirectory(final InputStream in
127124
}
128125
return true;
129126
}
127+
128+
private static synchronized void unzipArchive(final File archive, final File destinationDir) {
129+
try(ZipFile zipFile = new ZipFile(archive))
130+
{
131+
FileSystem fileSystem = FileSystems.getDefault();
132+
133+
destinationDir.mkdirs();
134+
135+
Enumeration<? extends ZipEntry> entries = zipFile.entries();
136+
137+
while (entries.hasMoreElements())
138+
{
139+
ZipEntry entry = entries.nextElement();
140+
141+
Path filePath = fileSystem.getPath(destinationDir.getAbsolutePath(), entry.getName());
142+
143+
System.out.println("Unzipping file to: " + filePath.toString());
144+
145+
if (entry.isDirectory())
146+
{
147+
Files.createDirectories(filePath);
148+
}
149+
else
150+
{
151+
InputStream is = zipFile.getInputStream(entry);
152+
BufferedInputStream bis = new BufferedInputStream(is);
153+
Files.createFile(filePath);
154+
FileOutputStream fileOutput = new FileOutputStream(filePath.toFile());
155+
while (bis.available() > 0)
156+
{
157+
fileOutput.write(bis.read());
158+
}
159+
fileOutput.close();
160+
}
161+
}
162+
}
163+
catch(IOException e)
164+
{
165+
e.printStackTrace();
166+
}
167+
}
130168
}

0 commit comments

Comments
 (0)