1 29 30 package com.caucho.quercus.lib.file; 31 32 import com.caucho.quercus.env.BooleanValue; 33 import com.caucho.quercus.env.Env; 34 import com.caucho.quercus.env.LongValue; 35 import com.caucho.quercus.env.StringValue; 36 import com.caucho.quercus.env.Value; 37 import com.caucho.util.L10N; 38 39 import java.io.IOException ; 40 41 public class PhpProtocolWrapper extends ProtocolWrapper { 42 private static final L10N L = new L10N(PhpProtocolWrapper.class); 43 44 public PhpProtocolWrapper() 45 { 46 } 47 48 public BinaryStream fopen(Env env, StringValue path, StringValue mode, 49 LongValue options) 50 { 51 if (path.toString().equals("php://output")) { 52 return new PhpBinaryOutput(env); 53 } else { 54 env.warning(L.l("{0} is an unsupported or unknown path for this protocol", 55 path.toString())); 56 57 return null; 58 } 59 } 60 61 public Value opendir(Env env, StringValue path, LongValue flags) 62 { 63 env.warning(L.l("opendir not supported by protocol")); 64 65 return BooleanValue.FALSE; 66 } 67 68 public boolean unlink(Env env, StringValue path) 69 { 70 env.warning(L.l("unlink not supported by protocol")); 71 72 return false; 73 } 74 75 public boolean rename(Env env, StringValue path_from, StringValue path_to) 76 { 77 env.warning(L.l("rename not supported by protocol")); 78 79 return false; 80 } 81 82 public boolean mkdir(Env env, 83 StringValue path, LongValue mode, LongValue options) 84 { 85 env.warning(L.l("mkdir not supported by protocol")); 86 87 return false; 88 } 89 90 public boolean rmdir(Env env, StringValue path, LongValue options) 91 { 92 env.warning(L.l("rmdir not supported by protocol")); 93 94 return false; 95 } 96 97 public Value url_stat(Env env, StringValue path, LongValue flags) 98 { 99 env.warning(L.l("stat not supported by protocol")); 100 101 return BooleanValue.FALSE; 102 } 103 104 private class PhpBinaryOutput extends AbstractBinaryOutput { 105 private Env _env; 106 107 public PhpBinaryOutput(Env env) 108 { 109 _env = env; 110 } 111 112 115 public void write(byte []buffer, int offset, int length) 116 throws IOException 117 { 118 _env.getOut().write(buffer, offset, length); 119 } 120 121 public void write(int b) 122 throws IOException 123 { 124 _env.getOut().write(b); 125 } 126 } 127 } 128 129 | Popular Tags |