示例#1
0
文件: spl.py 项目: CodeOps/hippyvm
def sfo_construct(interp, this, filename, open_mode='r',
                  use_include_path=False, w_ctx=None):
    this.file_name = filename
    this.path_name = rpath.realpath(filename)
    this.delimiter = ","
    this.enclosure = '"'
    this.flags = 0
    this.open_mode = open_mode
    this.use_include_path = use_include_path
    this.w_res = None
    this.max_line_len = 0

    if w_ctx:
        if not interp.space.is_resource(w_ctx):
            raise PHPException(k_RuntimeException.call_args(
                interp, [interp.space.wrap(
                    "SplFileObject::__construct() expects "
                    "parameter 4 to be resource, %s given"
                    % interp.space.get_type_name(w_ctx.tp).lower())]))

    assert filename is not None
    if os.path.isdir(filename):
        raise interp.throw("Cannot use SplFileObject with directories",
                           klass=k_LogicException)
    try:
        this.w_res = _fopen(interp.space, filename, this.open_mode,
                            use_include_path, w_ctx)
        if this.w_res == interp.space.w_False:
            raise PHPException(k_RuntimeException.call_args(
                interp, [interp.space.wrap(
                    "SplFileObject::__construct(): Failed to open stream")]))
    except FopenError as e:
        raise PHPException(k_RuntimeException.call_args(interp,
            [interp.space.wrap(e.reasons.pop())]))
示例#2
0
文件: funcs.py 项目: youaani/hippyvm
def stream_resolve_include_path(interp, filename):
    """ Resolve filename against the include path"""

    for path in interp.include_path:
        fullpath = rpath.join(path, [filename])
        if rpath.exists(fullpath):
            return interp.space.wrap(rpath.realpath(fullpath))

    return interp.space.w_False
示例#3
0
文件: spl.py 项目: youaani/hippyvm
def sfo_construct(interp,
                  this,
                  filename,
                  open_mode='r',
                  use_include_path=False,
                  w_ctx=None):
    this.file_name = filename
    this.path_name = rpath.realpath(filename)
    this.delimiter = ","
    this.enclosure = '"'
    this.flags = 0
    this.open_mode = open_mode
    this.use_include_path = use_include_path
    this.w_res = None
    this.max_line_len = 0

    if w_ctx:
        if not interp.space.is_resource(w_ctx):
            raise PHPException(
                k_RuntimeException.call_args(interp, [
                    interp.space.wrap(
                        "SplFileObject::__construct() expects "
                        "parameter 4 to be resource, %s given" %
                        interp.space.get_type_name(w_ctx.tp).lower())
                ]))

    assert filename is not None
    if os.path.isdir(filename):
        raise interp.throw("Cannot use SplFileObject with directories",
                           klass=k_LogicException)
    try:
        this.w_res = _fopen(interp.space, filename, this.open_mode,
                            use_include_path, w_ctx)
        if this.w_res == interp.space.w_False:
            raise PHPException(
                k_RuntimeException.call_args(interp, [
                    interp.space.wrap(
                        "SplFileObject::__construct(): Failed to open stream")
                ]))
    except FopenError as e:
        raise PHPException(
            k_RuntimeException.call_args(interp,
                                         [interp.space.wrap(e.reasons.pop())]))
示例#4
0
文件: spl.py 项目: CodeOps/hippyvm
def construct(interp, this, file_name):
    this.file_name = file_name
    this.path_name = rpath.realpath(file_name)
示例#5
0
文件: spl.py 项目: CodeOps/hippyvm
def get_realpath(interp, this):
    try:
        path = rpath.realpath(this.file_name)
        return interp.space.wrap(path)
    except OSError:
        return interp.space.w_False
示例#6
0
def getFileName(interp, this):
    filename = rpath.realpath(this.refl_klass.decl.reflection.filename)
    return interp.space.wrap(filename)
示例#7
0
文件: spl.py 项目: youaani/hippyvm
def construct(interp, this, file_name):
    this.file_name = file_name
    this.path_name = rpath.realpath(file_name)
示例#8
0
文件: spl.py 项目: youaani/hippyvm
def get_realpath(interp, this):
    try:
        path = rpath.realpath(this.file_name)
        return interp.space.wrap(path)
    except OSError:
        return interp.space.w_False