- fixed that unzip will name the files correctly even if in the zip

the filename is other one
This commit is contained in:
pavol.zibrita 2011-01-21 07:25:56 +01:00
parent a68d4b1ce3
commit 3fd934753a

View file

@ -680,21 +680,27 @@ public class DownloadIndexActivity extends ListActivity {
} }
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(fileToDownload)); ZipInputStream zipIn = new ZipInputStream(new FileInputStream(fileToDownload));
ZipEntry entry = null; ZipEntry entry = null;
boolean first = true;
while ((entry = zipIn.getNextEntry()) != null) { while ((entry = zipIn.getNextEntry()) != null) {
File fs; File fs;
if (!unzipToDir) { if (!unzipToDir) {
String name = entry.getName(); if (first) {
// small simplification fs = toIndex;
int ind = name.lastIndexOf('_'); first = false;
if (ind > 0) { } else {
// cut version String name = entry.getName();
int i = name.indexOf('.', ind); // small simplification
if (i > 0) { int ind = name.lastIndexOf('_');
name = name.substring(0, ind) + name.substring(i, name.length()); if (ind > 0) {
// cut version
int i = name.indexOf('.', ind);
if (i > 0) {
name = name.substring(0, ind) + name.substring(i, name.length());
}
} }
fs = new File(fileToUnZip.getParent(), name);
toIndex = fs;
} }
fs = new File(fileToUnZip.getParent(), name);
} else { } else {
fs = new File(fileToUnZip, entry.getName()); fs = new File(fileToUnZip, entry.getName());
} }