KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > quercus > lib > file > ZlibProtocolWrapper


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Emil Ong
28  */

29
30 package com.caucho.quercus.lib.file;
31
32 import com.caucho.quercus.env.*;
33 import com.caucho.quercus.lib.UrlModule;
34 import com.caucho.quercus.lib.zlib.ZlibModule;
35 import com.caucho.util.L10N;
36
37 import java.util.logging.Logger JavaDoc;
38
39 public class ZlibProtocolWrapper extends ProtocolWrapper {
40   private static final Logger JavaDoc log
41     = Logger.getLogger(ZlibProtocolWrapper.class.getName());
42   private static final L10N L = new L10N(ZlibProtocolWrapper.class);
43
44   public ZlibProtocolWrapper()
45   {
46   }
47
48   public BinaryStream fopen(Env env, StringValue path, StringValue mode,
49                             LongValue options)
50   {
51     boolean useIncludePath =
52       (options.toLong() & StreamModule.STREAM_USE_PATH) != 0;
53
54     ArrayValue components =
55       (ArrayValue) UrlModule.parse_url(env, path.toString());
56
57     Value pathComponent = components.get(new StringValueImpl("path"));
58     
59     if (pathComponent == UnsetValue.UNSET) {
60       log.info(L.l("no path component found in '{0}'", path.toString()));
61       return null;
62     }
63
64     return ZlibModule.gzopen(env, pathComponent.toString(), mode.toString(),
65                              useIncludePath);
66   }
67
68   public Value opendir(Env env, StringValue path, LongValue flags)
69   {
70     env.warning(L.l("opendir not supported by protocol"));
71
72     return BooleanValue.FALSE;
73   }
74
75   public boolean unlink(Env env, StringValue path)
76   {
77     env.warning(L.l("unlink not supported by protocol"));
78
79     return false;
80   }
81
82   public boolean rename(Env env, StringValue path_from, StringValue path_to)
83   {
84     env.warning(L.l("rename not supported by protocol"));
85
86     return false;
87   }
88
89   public boolean mkdir(Env env,
90                        StringValue path, LongValue mode, LongValue options)
91   {
92     env.warning(L.l("mkdir not supported by protocol"));
93
94     return false;
95   }
96
97   public boolean rmdir(Env env, StringValue path, LongValue options)
98   {
99     env.warning(L.l("rmdir not supported by protocol"));
100
101     return false;
102   }
103
104   public Value url_stat(Env env, StringValue path, LongValue flags)
105   {
106     env.warning(L.l("stat not supported by protocol"));
107
108     return BooleanValue.FALSE;
109   }
110
111
112 }
113
114
Popular Tags