Exemple #1
0
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 PHPException(k_LogicException.call_args(
            interp, [interp.space.wrap(
                "Cannot use SplFileObject with directories")]))
    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())]))
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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 PHPException(
            k_LogicException.call_args(interp, [
                interp.space.wrap("Cannot use SplFileObject with directories")
            ]))
    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())]))
Exemple #5
0
def construct(interp, this, file_name):
    this.file_name = file_name
    this.path_name = rpath.realpath(file_name)
Exemple #6
0
def get_realpath(interp, this):
    try:
        path = rpath.realpath(this.file_name)
        return interp.space.wrap(path)
    except OSError:
        return interp.space.w_False
Exemple #7
0
def construct(interp, this, file_name):
    this.file_name = file_name
    this.path_name = rpath.realpath(file_name)
Exemple #8
0
def get_realpath(interp, this):
    try:
        path = rpath.realpath(this.file_name)
        return interp.space.wrap(path)
    except OSError:
        return interp.space.w_False
Exemple #9
0
def reflection_class_get_file_name(interp, this):
    filename = rpath.realpath(this.refl_klass.decl.reflection.filename)
    return interp.space.wrap(filename)
Exemple #10
0
def reflection_class_get_file_name(interp, this):
    filename = rpath.realpath(this.refl_klass.decl.reflection.filename)
    return interp.space.wrap(filename)