1 29 30 package com.caucho.quercus.lib.zip; 31 32 import com.caucho.quercus.lib.file.BinaryInput; 33 import com.caucho.quercus.lib.file.ReadStreamInput; 34 import com.caucho.vfs.*; 35 36 import java.io.IOException ; 37 import java.util.zip.ZipEntry ; 38 import java.util.zip.ZipInputStream ; 39 40 45 public class ZipEntryInputStream extends ReadStreamInput 46 { 47 private BinaryInput _in; 48 private ZipInputStream _zipIn; 49 private QuercusZipEntry _entry; 50 51 public ZipEntryInputStream(BinaryInput in, QuercusZipEntry entry) 52 throws IOException 53 { 54 init(in, entry); 55 } 56 57 protected void init(BinaryInput in, QuercusZipEntry entry) 58 throws IOException 59 { 60 in.setPosition(entry.getPosition()); 61 62 _in = in; 63 _zipIn = new ZipInputStream (in.getInputStream()); 64 _entry = entry; 65 66 ZipEntry curEntry = _zipIn.getNextEntry(); 67 68 if (curEntry == null) 69 throw new IOException ("Zip entry " + 70 entry.getZipEntry().getName() + " not found."); 71 72 init(new ReadStream(new VfsStream(_zipIn, null))); 73 } 74 75 78 public BinaryInput openCopy() 79 throws IOException 80 { 81 return new ZipEntryInputStream(_in.openCopy(), _entry); 82 } 83 84 public String toString() 85 { 86 return "ZipEntryInputStream[]"; 87 } 88 } 89 | Popular Tags |