public bool unlink(Env env, StringValue path)
        {
            // php/1e23
            Value            obj      = _qClass.createObject(env);
            AbstractFunction function = _qClass.findFunction("unlink");

            if (function == null)
            {
                return(false);
            }

            Value result = function.callMethod(env, _qClass, obj, path);

            return(result.toBoolean());
        }
示例#2
0
        public Value unserialize(Env env)

        {
            int ch = read();

            switch (ch)
            {
            case 'b':
            {
                expect(':');
                long v = readInt();
                expect(';');

                Value value = v == 0 ? BooleanValue.FALSE : BooleanValue.TRUE;

                if (_useReference)
                {
                    value = createReference(value);
                }

                return(value);
            }

            case 's':
            case 'S':
            case 'u':
            case 'U':
            {
                expect(':');
                int len = (int)readInt();
                expect(':');
                expect('"');

                if (!isValidString(len))
                {
                    env.notice(L.l("expected string length of {0}", len));
                    return(BooleanValue.FALSE);
                }

                Value value;

                if (ch == 's' || ch == 'S')
                {
                    value = readStringValue(env, len);
                }
                else
                {
                    value = readUnicodeValue(env, len);
                }

                expect('"');
                expect(';');

                if (_useReference)
                {
                    value = createReference(value);
                }

                return(value);
            }

            case 'i':
            {
                expect(':');

                long l = readInt();

                expect(';');

                Value value = LongValue.create(l);

                if (_useReference)
                {
                    value = createReference(value);
                }

                return(value);
            }

            case 'd':
            {
                expect(':');

                StringBuilder sb = new StringBuilder();
                for (ch = read(); ch >= 0 && ch != ';'; ch = read())
                {
                    sb.append((char)ch);
                }

                if (ch != ';')
                {
                    throw new IOException(L.l("expected ';'"));
                }

                Value value = new DoubleValue(Double.parseDouble(sb.ToString()));

                if (_useReference)
                {
                    value = createReference(value);
                }

                return(value);
            }

            case 'a':
            {
                expect(':');
                int len = (int)readInt();
                expect(':');
                expect('{');

                Value array = new ArrayValueImpl(len);

                if (_useReference)
                {
                    array = createReference(array);
                }

                for (int i = 0; i < len; i++)
                {
                    Value key   = unserializeKey(env);
                    Value value = unserialize(env);

                    array.put(key, value);
                }

                expect('}');

                return(array);
            }

            case 'O':
            {
                expect(':');
                int len = (int)readInt();
                expect(':');
                expect('"');

                if (!isValidString(len))
                {
                    return(BooleanValue.FALSE);
                }

                string className = readString(len);

                expect('"');
                expect(':');
                int count = (int)readInt();
                expect(':');
                expect('{');

                QuercusClass qClass = env.findClass(className);
                Value        obj;

                if (qClass != null)
                {
                    obj = qClass.createObject(env);
                }
                else
                {
                    log.fine(L.l("{0} @is an undefined class in unserialize",
                                 className));

                    obj = env.createIncompleteObject(className);
                }

                Value ref = null;

                if (_useReference)
                {
                    ref = createReference(obj);
                }

                for (int i = 0; i < count; i++)
                {
                    StringValue key = unserializeKey(env).ToStringValue();

                    FieldVisibility visibility = FieldVisibility.PUBLIC;

                    if (key.length() == 0)
                    {
                        throw new IOException(L.l("field key @is empty for class {0})",
                                                  className));
                    }

                    if (key[0] == 0)
                    {
                        if (key.length() > 3 &&
                            key[1] == '*' &&
                            key[2] == 0)
                        {
                            visibility = FieldVisibility.PROTECTED;

                            //key = key.substring(3);
                        }
                        else if (key.length() > 4)
                        {
                            int end = key.indexOf("\u0000", 1);

                            if (end < 0)
                            {
                                throw new IOException(L.l("end of field visibility modifier @is not valid: 0x{0} ({1}, {2})",
                                                          Integer.toHexString(key[2]), className, key));
                            }

                            StringValue declaringClass = key.substring(1, end);
                            StringValue fieldName      = key.substring(end + 1);

                            visibility = FieldVisibility.PRIVATE;
                        }
                        else
                        {
                            throw new IOException(L.l("field visibility modifier @is not valid: 0x{0} ({1}, {2})",
                                                      Integer.toHexString(key[1]), className, key));
                        }
                    }

                    Value value = unserialize(env);

                    obj.initIncompleteField(env, key, value, visibility);
                }

                expect('}');

                if (ref != null)
                {
                    return(ref);
                }
                else
                {
                    return(obj);
                }
            }