Ruby  3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
Typedefs | Functions
glob.h File Reference

(0989400a925cd201defdca9eb28eb87200b30785)

Declares rb_glob(). More...

#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Include dependency graph for glob.h:
This graph shows which files directly or indirectly include this file:

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. More...
 

Functions

void rb_glob (const char *pattern, void(*func)(const char *path, VALUE arg, void *enc), VALUE arg)
 The "glob" operator. More...
 
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. More...
 
int ruby_brace_glob (const char *pattern, int flags, ruby_glob_func *func, VALUE arg)
 Identical to ruby_glob(), @shyouhei currently suspects. More...
 

Detailed Description

Declares rb_glob().

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
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]pathThe path in question.
[in]argThe argument passed to rb_glob().
[in]encEncoding of the path.
Return values
-1Not enough memory to do the operation.
0Operation successful.
otherwiseOpaque 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(*)(const char *path, VALUE arg, void *enc)  func,
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]patternA glob pattern.
[in]funcIdentical to ruby_glob_func, except it can raise exceptions instead of returning opaque state.
[in]argExtra argument passed to func.
Exceptions
rb_eExceptionCan propagate what func raises.
Note
The language accepted as the pattern is not a regular expression. It resembles shell's glob.

◆ 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]patternA glob pattern.
[in]flagsNo, you are not allowed to use this. Just pass 0.
[in]funcA callback function.
[in]argExtra 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]patternA glob pattern.
[in]flagsNo, you are not allowed to use this. Just pass 0.
[in]funcA callback function.
[in]argExtra argument passed to func.
Returns
Return value of func.

Definition at line 3139 of file dir.c.