1 29 30 package com.caucho.quercus.lib.file; 31 32 import com.caucho.quercus.env.Env; 33 import com.caucho.vfs.ReadStream; 34 import com.caucho.vfs.VfsStream; 35 36 import java.io.IOException ; 37 import java.util.logging.Logger ; 38 39 42 public class PopenInput extends ReadStreamInput { 43 private static final Logger log 44 = Logger.getLogger(FileInput.class.getName()); 45 46 private Env _env; 47 private Process _process; 48 49 public PopenInput(Env env, Process process) 50 throws IOException 51 { 52 _env = env; 53 54 _env.addClose(this); 55 56 _process = process; 57 58 init(new ReadStream(new VfsStream(_process.getInputStream(), null))); 59 60 _process.getOutputStream().close(); 61 } 62 63 66 public BinaryInput openCopy() 67 throws IOException 68 { 69 return new PopenInput(_env, _process); 70 } 71 72 75 public long getLength() 76 { 77 return 0; 78 } 79 80 83 public String toString() 84 { 85 return "PopenInput[" + _process + "]"; 86 } 87 88 public void close() 89 { 90 pclose(); 91 } 92 93 public int pclose() 94 { 95 super.close(); 96 97 try { 98 return _process.waitFor(); 99 } catch (Exception e) { 100 return -1; 101 } finally { 102 _env.removeClose(this); 103 } 104 } 105 } 106 107 | Popular Tags |