forked from Qortal/qortal
Show progress status when extracting files
This commit is contained in:
parent
65dca36ae1
commit
ddf966d08c
@ -9,6 +9,7 @@ package org.qortal.utils;
|
|||||||
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
|
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
|
||||||
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
|
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
|
||||||
import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;
|
import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;
|
||||||
|
import org.qortal.gui.SplashFrame;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@ -38,12 +39,19 @@ public class SevenZ {
|
|||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
parent.mkdirs();
|
parent.mkdirs();
|
||||||
}
|
}
|
||||||
|
long fileSize = entry.getSize();
|
||||||
|
|
||||||
FileOutputStream out = new FileOutputStream(curfile);
|
FileOutputStream out = new FileOutputStream(curfile);
|
||||||
byte[] b = new byte[8192];
|
byte[] b = new byte[1024 * 1024];
|
||||||
int count = 0;
|
int count;
|
||||||
|
long downloaded = 0;
|
||||||
|
|
||||||
while ((count = sevenZFile.read(b)) > 0) {
|
while ((count = sevenZFile.read(b)) > 0) {
|
||||||
out.write(b, 0, count);
|
out.write(b, 0, count);
|
||||||
|
downloaded += count;
|
||||||
|
|
||||||
|
int progress = (int)((double)downloaded / (double)fileSize * 100);
|
||||||
|
SplashFrame.getInstance().updateStatus(String.format("Extracting %s... (%d%%)", curfile.getName(), progress));
|
||||||
}
|
}
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user