001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.quercus.lib.file;
031:
032: import com.caucho.quercus.env.*;
033: import com.caucho.quercus.lib.UrlModule;
034: import com.caucho.quercus.lib.zlib.ZlibModule;
035: import com.caucho.util.L10N;
036:
037: import java.util.logging.Logger;
038:
039: public class ZlibProtocolWrapper extends ProtocolWrapper {
040: private static final Logger log = Logger
041: .getLogger(ZlibProtocolWrapper.class.getName());
042: private static final L10N L = new L10N(ZlibProtocolWrapper.class);
043:
044: public ZlibProtocolWrapper() {
045: }
046:
047: public BinaryStream fopen(Env env, StringValue path,
048: StringValue mode, LongValue options) {
049: boolean useIncludePath = (options.toLong() & StreamModule.STREAM_USE_PATH) != 0;
050:
051: ArrayValue components = (ArrayValue) UrlModule.parse_url(env,
052: path);
053:
054: Value pathComponent = components.get(env.createString("path"));
055:
056: if (pathComponent == UnsetValue.UNSET) {
057: log.info(L.l("no path component found in '{0}'", path
058: .toString()));
059: return null;
060: }
061:
062: return ZlibModule.gzopen(env, pathComponent.toStringValue(),
063: mode.toString(), useIncludePath);
064: }
065:
066: public Value opendir(Env env, StringValue path, LongValue flags) {
067: env.warning(L.l("opendir not supported by protocol"));
068:
069: return BooleanValue.FALSE;
070: }
071:
072: public boolean unlink(Env env, StringValue path) {
073: env.warning(L.l("unlink not supported by protocol"));
074:
075: return false;
076: }
077:
078: public boolean rename(Env env, StringValue path_from,
079: StringValue path_to) {
080: env.warning(L.l("rename not supported by protocol"));
081:
082: return false;
083: }
084:
085: public boolean mkdir(Env env, StringValue path, LongValue mode,
086: LongValue options) {
087: env.warning(L.l("mkdir not supported by protocol"));
088:
089: return false;
090: }
091:
092: public boolean rmdir(Env env, StringValue path, LongValue options) {
093: env.warning(L.l("rmdir not supported by protocol"));
094:
095: return false;
096: }
097:
098: public Value url_stat(Env env, StringValue path, LongValue flags) {
099: env.warning(L.l("stat not supported by protocol"));
100:
101: return BooleanValue.FALSE;
102: }
103:
104: }
|