mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Removed some ziptool stuff
Well as it was removed from here, it may aswell just be removed from this file too :)
This commit is contained in:
parent
5868540cbb
commit
f63805cca2
@ -305,76 +305,7 @@ public class TFM_Util
|
||||
return TFM_Util.mobtypes.get(mobname);
|
||||
}
|
||||
|
||||
public static void zip(File directory, File zipfile, boolean verbose, CommandSender sender) throws IOException
|
||||
{
|
||||
URI base = directory.toURI();
|
||||
Deque<File> queue = new LinkedList<File>();
|
||||
queue.push(directory);
|
||||
OutputStream out = new FileOutputStream(zipfile);
|
||||
Closeable res = out;
|
||||
try
|
||||
{
|
||||
ZipOutputStream zout = new ZipOutputStream(out);
|
||||
res = zout;
|
||||
while (!queue.isEmpty())
|
||||
{
|
||||
directory = queue.pop();
|
||||
for (File kid : directory.listFiles())
|
||||
{
|
||||
String name = base.relativize(kid.toURI()).getPath();
|
||||
if (kid.isDirectory())
|
||||
{
|
||||
queue.push(kid);
|
||||
name = name.endsWith("/") ? name : name + "/";
|
||||
zout.putNextEntry(new ZipEntry(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
zout.putNextEntry(new ZipEntry(name));
|
||||
copy(kid, zout);
|
||||
zout.closeEntry();
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
sender.sendMessage("Zipping: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
res.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void unzip(File zipfile, File directory) throws IOException
|
||||
{
|
||||
ZipFile zfile = new ZipFile(zipfile);
|
||||
Enumeration<? extends ZipEntry> entries = zfile.entries();
|
||||
while (entries.hasMoreElements())
|
||||
{
|
||||
ZipEntry entry = entries.nextElement();
|
||||
File file = new File(directory, entry.getName());
|
||||
if (entry.isDirectory())
|
||||
{
|
||||
file.mkdirs();
|
||||
}
|
||||
else
|
||||
{
|
||||
file.getParentFile().mkdirs();
|
||||
InputStream in = zfile.getInputStream(entry);
|
||||
try
|
||||
{
|
||||
copy(in, file);
|
||||
}
|
||||
finally
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(InputStream in, OutputStream out) throws IOException
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user