public Scanner(BaseActivity coolReader, Engine engine) { this.engine = engine; this.mActivity = coolReader; mRoot = new FileInfo(); mRoot.path = FileInfo.ROOT_DIR_TAG; mRoot.filename = "File Manager"; mRoot.pathname = FileInfo.ROOT_DIR_TAG; mRoot.isListed = true; mRoot.isScanned = true; mRoot.isDirectory = true; }
private FileInfo scanZip(FileInfo zip) { try { File zf = new File(zip.pathname); long arcsize = zf.length(); // ZipFile file = new ZipFile(zf); ArrayList<ZipEntry> entries = engine.getArchiveItems(zip.pathname); ArrayList<FileInfo> items = new ArrayList<FileInfo>(); // for ( Enumeration<?> e = file.entries(); e.hasMoreElements(); ) { for (ZipEntry entry : entries) { if (entry.isDirectory()) continue; String name = entry.getName(); FileInfo item = new FileInfo(); item.format = DocumentFormat.byExtension(name); if (item.format == null) continue; File f = new File(name); item.filename = f.getName(); item.path = f.getPath(); item.pathname = entry.getName(); item.size = (int) entry.getSize(); // item.createTime = entry.getTime(); item.createTime = zf.lastModified(); item.arcname = zip.pathname; item.arcsize = (int) entry.getCompressedSize(); item.isArchive = true; items.add(item); } if (items.size() == 0) { L.i("Supported files not found in " + zip.pathname); return null; } else if (items.size() == 1) { // single supported file in archive FileInfo item = items.get(0); item.isArchive = true; item.isDirectory = false; return item; } else { zip.isArchive = true; zip.isDirectory = true; zip.isListed = true; for (FileInfo item : items) { item.parent = zip; zip.addFile(item); } return zip; } } catch (Exception e) { L.e("IOException while opening " + zip.pathname + " " + e.getMessage()); } return null; }