Ruby: include/ruby/internal/glob.h File Reference

Ruby 3.4.3p32 (2025-04-14 revision d0b7e5b6a04bde21ca483d20a1546b28b401c2d4)

Typedefs | Functions
glob.h File Reference

Declares rb_glob(). More...

`#include "ruby/internal/attr/nonnull.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Typedefs
typedef int | ruby_glob_func(const char *path, VALUE arg, void *enc)
| Type of a glob callback function.

## Functions
void | rb_glob (const char *pattern, void(*func)(const char *path, VALUE arg, void *enc), VALUE arg)
| The "glob" operator.
int | ruby_glob (const char *pattern, int flags, ruby_glob_func *func, VALUE arg)
| Identical to rb_glob(), except it returns opaque exception states instead of raising exceptions.
int | ruby_brace_glob (const char *pattern, int flags, ruby_glob_func *func, VALUE arg)
| Identical to ruby_glob(), @shyouhei currently suspects.

## Detailed Description

Declares rb_glob().

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file glob.h.

## Typedef Documentation

## ◆ ruby_glob_func

typedef int ruby_glob_func(const char *path, VALUE arg, void *enc)

Type of a glob callback function.

Called every time glob scans a path.

Parameters

  [in] | path | The path in question.
  [in] | arg | The argument passed to rb_glob().
  [in] | enc | Encoding of the path.

Return values

  -1 | Not enough memory to do the operation.
  0 | Operation successful.
  otherwise | Opaque exception state.

Note
  You can use rb_protect() to generate the return value.

Definition at line 49 of file glob.h.

## Function Documentation

## ◆ rb_glob()

void rb_glob | ( | const char * | pattern,
|  | void(* | func )(const char *path, VALUE arg, void *enc),
|  | VALUE | arg )

The "glob" operator.

Expands the given pattern against the actual local filesystem, then iterates over the expanded filenames by calling the callback function.

Parameters

  [in] | pattern | A glob pattern.
  [in] | func | Identical to ruby_glob_func, except it can raise exceptions instead of returning opaque state.
  [in] | arg | Extra argument passed to func.

Exceptions

  rb_eException | Can propagate what `func` raises.

Note
  The language accepted as the pattern is not a regular expression. It resembles shell's glob.

Definition at line 3164 of file dir.c.

## ◆ ruby_brace_glob()

int ruby_brace_glob | ( | const char * | pattern,
|  | int | flags,
|  | ruby_glob_func * | func,
|  | VALUE | arg )

Identical to ruby_glob(), @shyouhei currently suspects.

Historically you had to call this function instead of ruby_glob() if the pattern included "{x,y,...}" syntax. However since commit 0f63d961169989a7f6dcf7c0487fe29da, ruby_glob() also supports that syntax. It seems as of writing these two functions provide basically the same functionality in a different implementation. Is this analysis right? Correct me! :FIXME:

Parameters

  [in] | pattern | A glob pattern.
  [in] | flags | No, you are not allowed to use this. Just pass 0.
  [in] | func | A callback function.
  [in] | arg | Extra argument passed to func.

Returns
  Return value of `func`.

Definition at line 3279 of file dir.c.

## ◆ ruby_glob()

int ruby_glob | ( | const char * | pattern,
|  | int | flags,
|  | ruby_glob_func * | func,
|  | VALUE | arg )

Identical to rb_glob(), except it returns opaque exception states instead of raising exceptions.

Parameters

  [in] | pattern | A glob pattern.
  [in] | flags | No, you are not allowed to use this. Just pass 0.
  [in] | func | A callback function.
  [in] | arg | Extra argument passed to func.

Returns
  Return value of `func`.

Definition at line 3139 of file dir.c.