Exemple #1
0
def di_construct(interp, this, path):
    if path == "":
        raise PHPException(k_RuntimeException.call_args(
            interp, [interp.space.wrap(
                "Directory name must not be empty.")]))
    this.path = path
    this.file_name = path
    this.index = 0
    if not os.path.isdir(path):
        raise PHPException(k_UnexpectedValueException.call_args(
            interp, [interp.space.wrap(
                "DirectoryIterator::__construct(%s): failed to open dir: No "
                "such file or directory" % path)]))
    try:
        w_dir = W_DirResource(interp.space, path)
        w_dir_res = w_dir.open()
        if not isinstance(w_dir_res, W_DirResource):
            raise OSError   # rare case, but annotation fix
        this.w_dir_res = w_dir_res
        this.path_name = _di_pathname(this)
    except OSError:
        raise PHPException(k_RuntimeException.call_args(
            interp, [interp.space.wrap(
                "DirectoryIterator::__construct(): error while opening stream"
            )]))
Exemple #2
0
def di_construct(interp, this, path):
    if path == "":
        raise PHPException(k_RuntimeException.call_args(
            interp, [interp.space.wrap(
                "Directory name must not be empty."
                )]))
    this.path = path
    this.file_name = path
    this.index = 0
    if not os.path.isdir(path):
        raise PHPException(k_UnexpectedValueException.call_args(
            interp, [interp.space.wrap(
                "DirectoryIterator::__construct(%s): failed to open dir: No "
                "such file or directory" % path)]))
    try:
        w_dir = W_DirResource(interp.space, path)
        w_dir_res = w_dir.open()
        if not isinstance(w_dir_res, W_DirResource):
            raise OSError   # rare case, but annotation fix
        this.w_dir_res = w_dir_res
        this.path_name = _di_pathname(this)
    except OSError:
        raise PHPException(k_RuntimeException.call_args(
            interp, [interp.space.wrap(
                "DirectoryIterator::__construct(): error while opening stream"
                )]))
Exemple #3
0
def rdi_construct(interp,
                  this,
                  path,
                  flags=FI_KEY_AS_PATHNAME | FI_CURRENT_AS_FILEINFO):
    if not os.path.isdir(path):
        raise PHPException(
            k_UnexpectedValueException.call_args(interp, [
                interp.space.wrap(
                    "RecursiveDirectoryIterator::__construct(%s): failed to open dir: No "
                    "such file or directory" % path)
            ]))
    this.flags = flags
    this.path = path
    this.file_name = path
    this.index = 0
    try:
        w_dir = W_DirResource(interp.space, path, this.flags & FI_SKIP_DOTS)
        w_dir_res = w_dir.open()
        if not isinstance(w_dir_res, W_DirResource):
            raise OSError
        this.w_dir_res = w_dir_res
        this.path_name = _di_pathname(this)
    except OSError:
        raise PHPException(
            k_RuntimeException.call_args(interp, [
                interp.space.wrap(
                    "RecursiveDirectoryIterator::__construct(): error while opening stream"
                )
            ]))
Exemple #4
0
def rdi_construct(interp, this, path, flags=
        FI_KEY_AS_PATHNAME | FI_CURRENT_AS_FILEINFO):
    if not os.path.isdir(path):
        raise PHPException(k_UnexpectedValueException.call_args(
            interp, [interp.space.wrap(
                "RecursiveDirectoryIterator::__construct(%s): failed to open dir: No "
                "such file or directory" % path)]))
    this.flags = flags
    this.path = path
    this.file_name = path
    this.index = 0
    try:
        w_dir = W_DirResource(interp.space, path, this.flags & FI_SKIP_DOTS)
        w_dir_res = w_dir.open()
        if not isinstance(w_dir_res, W_DirResource):
            raise OSError
        this.w_dir_res = w_dir_res
        this.path_name = _di_pathname(this)
    except OSError:
        raise PHPException(k_RuntimeException.call_args(
            interp, [interp.space.wrap(
                "RecursiveDirectoryIterator::__construct(): error while opening stream"
                )]))