// This string is autogenerated by ChangeAppSettings.sh, do not change // spaces amount package com.googlecode.opentyrian; import java.util.zip.*; import java.io.*; import android.util.Log; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import android.content.res.AssetManager; class AssetExtract { private AssetManager mAssetManager = null; AssetExtract(AssetManager am) { mAssetManager = am; } public boolean extract(String asset, String target) { byte buf[] = new byte[1024 * 1024]; InputStream assetStream = null; try { assetStream = mAssetManager.open(asset, AssetManager.ACCESS_RANDOM); } catch (IOException e) { // TODO: Report error. return false; } ZipInputStream zip = new ZipInputStream(assetStream); while (true) { ZipEntry entry = null; try { entry = zip.getNextEntry(); } catch ( java.io.IOException e ) { // Todo: Error out. return false; } if ( entry == null ) { break; } Log.i("AssetExtract", "Extracting " + entry.getName()); if (entry.isDirectory()) { try { new File(target +"/" + entry.getName()).mkdirs(); } catch ( SecurityException e ) { }; continue; } OutputStream out = null; String path = target + "/" + entry.getName(); try { out = new FileOutputStream( path ); } catch ( FileNotFoundException e ) { } catch ( SecurityException e ) { }; if ( out == null ) { // TODO: Error. return false; } try { while (true) { int len = zip.read(buf); if (len == -1) { break; } out.write(buf, 0, len); } out.flush(); out.close(); } catch ( java.io.IOException e ) { // TODO: Deal w/ error. return false; } } try { zip.close(); assetStream.close(); } catch (IOException e) { // pass } return true; } }