- 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,9 +680,14 @@ 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) {
if (first) {
fs = toIndex;
first = false;
} else {
String name = entry.getName(); String name = entry.getName();
// small simplification // small simplification
int ind = name.lastIndexOf('_'); int ind = name.lastIndexOf('_');
@ -694,7 +699,8 @@ public class DownloadIndexActivity extends ListActivity {
} }
} }
fs = new File(fileToUnZip.getParent(), name); fs = new File(fileToUnZip.getParent(), name);
toIndex = fs;
}
} else { } else {
fs = new File(fileToUnZip, entry.getName()); fs = new File(fileToUnZip, entry.getName());
} }