1 29 30 package com.caucho.quercus.lib.zlib; 31 32 import com.caucho.quercus.QuercusModuleException; 33 import com.caucho.quercus.lib.file.BinaryInput; 34 import com.caucho.quercus.lib.file.ReadStreamInput; 35 import com.caucho.vfs.*; 36 37 import java.io.IOException ; 38 39 44 public class ZlibInputStream extends ReadStreamInput 45 { 46 private BinaryInput _in; 47 private GZInputStream _gzIn; 48 49 public ZlibInputStream(BinaryInput in) throws IOException 50 { 51 init(in); 52 } 53 54 protected void init(BinaryInput in) 55 throws IOException 56 { 57 _in = in; 58 59 _gzIn = new GZInputStream(in.getInputStream()); 60 ReadStream rs = new ReadStream(new VfsStream(_gzIn, null)); 61 62 init(rs); 63 } 64 65 68 public BinaryInput openCopy() 69 throws IOException 70 { 71 return new ZlibInputStream(_in.openCopy()); 72 } 73 74 77 public boolean setPosition(long offset) 78 { 79 try { 80 BinaryInput newIn = _in.openCopy(); 81 82 _gzIn.close(); 83 getInputStream().close(); 84 85 init(newIn); 86 87 if (offset > 0) 88 skip(offset); 89 90 return true; 91 } catch (IOException e) { 92 throw new QuercusModuleException(e); 93 } 94 } 95 96 public String toString() 97 { 98 return "ZlibInputStream[]"; 99 } 100 } 101 | Popular Tags |