commit 28bb6c31689b7c9ad65b630dcfdbac8c6e444b58 Author: Nathan Freitas nathan@freitas.net Date: Fri Oct 28 11:00:58 2011 -0400
binary installer now supports zipped raw files --- .../android/service/TorBinaryInstaller.java | 39 +++++++++++--------- 1 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/org/torproject/android/service/TorBinaryInstaller.java b/src/org/torproject/android/service/TorBinaryInstaller.java index 72f4ad3..b540f0c 100644 --- a/src/org/torproject/android/service/TorBinaryInstaller.java +++ b/src/org/torproject/android/service/TorBinaryInstaller.java @@ -9,8 +9,12 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.GZIPOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream;
import org.torproject.android.R; import org.torproject.android.TorConstants; @@ -40,29 +44,20 @@ public class TorBinaryInstaller implements TorServiceConstants { InputStream is; - is = context.getResources().openRawResource(R.raw.toraa); - streamToFile(is,installFolder, TOR_BINARY_ASSET_KEY, false); - - is = context.getResources().openRawResource(R.raw.torab); - streamToFile(is,installFolder, TOR_BINARY_ASSET_KEY, true); - - is = context.getResources().openRawResource(R.raw.torac); - streamToFile(is,installFolder, TOR_BINARY_ASSET_KEY, true); - - is = context.getResources().openRawResource(R.raw.torad); - streamToFile(is,installFolder, TOR_BINARY_ASSET_KEY, true); - + is = context.getResources().openRawResource(R.raw.tor); + streamToFile(is,installFolder, TOR_BINARY_ASSET_KEY, false, true); + is = context.getResources().openRawResource(R.raw.torrc); - streamToFile(is,installFolder, TORRC_ASSET_KEY, false); + streamToFile(is,installFolder, TORRC_ASSET_KEY, false, false);
is = context.getResources().openRawResource(R.raw.privoxy); - streamToFile(is,installFolder, PRIVOXY_ASSET_KEY, false); + streamToFile(is,installFolder, PRIVOXY_ASSET_KEY, false, false);
is = context.getResources().openRawResource(R.raw.privoxy_config); - streamToFile(is,installFolder, PRIVOXYCONFIG_ASSET_KEY, false); + streamToFile(is,installFolder, PRIVOXYCONFIG_ASSET_KEY, false, false); is = context.getResources().openRawResource(R.raw.geoip); - streamToFile(is,installFolder, GEOIP_ASSET_KEY, false); + streamToFile(is,installFolder, GEOIP_ASSET_KEY, false, true); return true; } @@ -71,7 +66,7 @@ public class TorBinaryInstaller implements TorServiceConstants { /* * Write the inputstream contents to the file */ - private static boolean streamToFile(InputStream stm, File folder, String targetFilename, boolean append) throws IOException + private static boolean streamToFile(InputStream stm, File folder, String targetFilename, boolean append, boolean zip) throws IOException
{ byte[] buffer = new byte[FILE_WRITE_BUFFER_SIZE]; @@ -80,7 +75,15 @@ public class TorBinaryInstaller implements TorServiceConstants {
File outFile = new File(folder, targetFilename);
- FileOutputStream stmOut = new FileOutputStream(outFile, append); + OutputStream stmOut = new FileOutputStream(outFile, append); + + if (zip) + { + ZipInputStream zis = new ZipInputStream(stm); + ZipEntry ze = zis.getNextEntry(); + stm = zis; + + } while ((bytecount = stm.read(buffer)) > 0)
tor-commits@lists.torproject.org