Ruby  2.1.10p492(2016-04-01revision54464)
Data Structures | Macros | Enumerations | Functions | Variables
dir.c File Reference
#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include "internal.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <ctype.h>
#include "ruby/util.h"

Go to the source code of this file.

Data Structures

struct  dir_data
 
struct  chdir_data
 
struct  glob_pattern
 
struct  glob_args
 
struct  brace_args
 

Macros

#define dirent   direct
 
#define NAMLEN(dirent)   (dirent)->d_namlen
 
#define HAVE_HFS   0
 
#define IF_HAVE_HFS(something)   /* nothing */
 
#define FNM_NOESCAPE   0x01
 
#define FNM_PATHNAME   0x02
 
#define FNM_DOTMATCH   0x04
 
#define FNM_CASEFOLD   0x08
 
#define FNM_EXTGLOB   0x10
 
#define FNM_SYSCASE   0
 
#define FNM_NOMATCH   1
 
#define FNM_ERROR   2
 
#define Next(p, e, enc)   ((p)+ rb_enc_mbclen((p), (e), (enc)))
 
#define Inc(p, e, enc)   ((p) = Next((p), (e), (enc)))
 
#define UNESCAPE(p)   (escape && *(p) == '\\' ? (p) + 1 : (p))
 
#define ISEND(p)   (!*(p) || (pathname && *(p) == '/'))
 
#define RETURN(val)   return *pcur = p, *scur = s, (val);
 
#define GlobPathValue(str, safe)
 
#define check_safe_glob(str, safe)   ((safe) ? rb_check_safe_obj(str) : (void)0)
 
#define check_glob_encoding(str)   rb_enc_check((str), rb_enc_from_encoding(rb_usascii_encoding()))
 
#define GetDIR(obj, dirp)   ((dirp) = dir_check(obj))
 
#define READDIR(dir, enc)   readdir((dir))
 
#define dir_tell   rb_f_notimplement
 
#define dir_seek   rb_f_notimplement
 
#define dir_set_pos   rb_f_notimplement
 
#define dir_s_chroot   rb_f_notimplement
 
#define GLOB_VERBOSE   (1U << (sizeof(int) * CHAR_BIT - 1))
 
#define sys_warning(val)   (void)((flags & GLOB_VERBOSE) && rb_protect(sys_warning_1, (VALUE)(val), 0))
 
#define GLOB_ALLOC(type)   ((type *)malloc(sizeof(type)))
 
#define GLOB_ALLOC_N(type, n)   ((type *)malloc(sizeof(type) * (n)))
 
#define GLOB_FREE(ptr)   free(ptr)
 
#define GLOB_JUMP_TAG(status)   (((status) == -1) ? rb_memerror() : rb_jump_tag(status))
 
#define to_be_ignored(e)   ((e) == ENOENT || (e) == ENOTDIR)
 
#define STAT(p, s)   stat((p), (s))
 
#define do_lstat   do_stat
 
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
 
#define S_ISLNK(m)   (0)
 
#define glob_call_func(func, path, arg, enc)   (*(func))((path), (arg), (enc))
 

Enumerations

enum  glob_pattern_type {
  PLAIN, MAGICAL, RECURSIVE, MATCH_ALL,
  MATCH_DIR
}
 
enum  answer { UNKNOWN = -1, NO, YES }
 

Functions

char * getenv ()
 
char * strchr (char *, char)
 
static char * bracket (const char *p, const char *pend, const char *s, const char *send, int flags, rb_encoding *enc)
 
static int fnmatch_helper (const char **pcur, const char **scur, int flags, rb_encoding *enc)
 
static int fnmatch (const char *pattern, rb_encoding *enc, const char *string, int flags)
 
static void dir_mark (void *ptr)
 
static void dir_free (void *ptr)
 
static size_t dir_memsize (const void *ptr)
 
static VALUE dir_close (VALUE)
 
static VALUE dir_s_alloc (VALUE klass)
 
static VALUE dir_initialize (int argc, VALUE *argv, VALUE dir)
 
static VALUE dir_s_open (int argc, VALUE *argv, VALUE klass)
 
static void dir_closed (void)
 
static struct dir_datadir_check (VALUE dir)
 
static VALUE dir_inspect (VALUE dir)
 
static VALUE dir_path (VALUE dir)
 
static VALUE dir_read (VALUE dir)
 
static VALUE dir_each (VALUE dir)
 
static VALUE dir_rewind (VALUE dir)
 
static void dir_chdir (VALUE path)
 
static VALUE chdir_yield (struct chdir_data *args)
 
static VALUE chdir_restore (struct chdir_data *args)
 
static VALUE dir_s_chdir (int argc, VALUE *argv, VALUE obj)
 
VALUE rb_dir_getwd (void)
 
static VALUE dir_s_getwd (VALUE dir)
 
static void check_dirname (volatile VALUE *dir)
 
static VALUE dir_s_mkdir (int argc, VALUE *argv, VALUE obj)
 
static VALUE dir_s_rmdir (VALUE obj, VALUE dir)
 
static VALUE sys_warning_1 (VALUE mesg)
 
static int do_stat (const char *path, struct stat *pst, int flags)
 
static DIRdo_opendir (const char *path, int flags, rb_encoding *enc)
 
static int has_magic (const char *p, const char *pend, int flags, rb_encoding *enc)
 
static char * find_dirsep (const char *p, const char *pend, int flags, rb_encoding *enc)
 
static char * remove_backslashes (char *p, register const char *pend, rb_encoding *enc)
 
static void glob_free_pattern (struct glob_pattern *list)
 
static struct glob_patternglob_make_pattern (const char *p, const char *e, int flags, rb_encoding *enc)
 
static char * join_path (const char *path, long len, int dirsep, const char *name, size_t namlen)
 
static VALUE glob_func_caller (VALUE val)
 
static int glob_helper (const char *path, int dirsep, enum answer exist, enum answer isdir, struct glob_pattern **beg, struct glob_pattern **end, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
 
static int ruby_glob0 (const char *path, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
 
int ruby_glob (const char *path, int flags, ruby_glob_func *func, VALUE arg)
 
static int rb_glob_caller (const char *path, VALUE a, void *enc)
 
static int rb_glob2 (const char *path, int flags, void(*func)(const char *, VALUE, void *), VALUE arg, rb_encoding *enc)
 
void rb_glob (const char *path, void(*func)(const char *, VALUE, void *), VALUE arg)
 
static void push_pattern (const char *path, VALUE ary, void *enc)
 
static int ruby_brace_expand (const char *str, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
 
static int glob_brace (const char *path, VALUE val, void *enc)
 
static int ruby_brace_glob0 (const char *str, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
 
int ruby_brace_glob (const char *str, int flags, ruby_glob_func *func, VALUE arg)
 
int ruby_brace_glob_with_enc (const char *str, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
 
static int push_glob (VALUE ary, VALUE str, int flags)
 
static VALUE rb_push_glob (VALUE str, int flags)
 
static VALUE dir_globs (long argc, const VALUE *argv, int flags)
 
static VALUE dir_s_aref (int argc, VALUE *argv, VALUE obj)
 
static VALUE dir_s_glob (int argc, VALUE *argv, VALUE obj)
 
static VALUE dir_open_dir (int argc, VALUE *argv)
 
static VALUE dir_foreach (int argc, VALUE *argv, VALUE io)
 
static VALUE dir_entries (int argc, VALUE *argv, VALUE io)
 
static int fnmatch_brace (const char *pattern, VALUE val, void *enc)
 
static VALUE file_s_fnmatch (int argc, VALUE *argv, VALUE obj)
 
static VALUE dir_s_home (int argc, VALUE *argv, VALUE obj)
 
static VALUE rb_dir_exists_p (VALUE obj, VALUE fname)
 
void Init_Dir (void)
 

Variables

VALUE rb_cDir
 
static const rb_data_type_t dir_data_type
 
static int chdir_blocking = 0
 
static VALUE chdir_thread = Qnil
 

Macro Definition Documentation

◆ check_glob_encoding

#define check_glob_encoding (   str)    rb_enc_check((str), rb_enc_from_encoding(rb_usascii_encoding()))

Definition at line 396 of file dir.c.

◆ check_safe_glob

#define check_safe_glob (   str,
  safe 
)    ((safe) ? rb_check_safe_obj(str) : (void)0)

Definition at line 395 of file dir.c.

◆ dir_s_chroot

#define dir_s_chroot   rb_f_notimplement

Definition at line 956 of file dir.c.

Referenced by Init_Dir().

◆ dir_seek

#define dir_seek   rb_f_notimplement

Definition at line 700 of file dir.c.

Referenced by Init_Dir().

◆ dir_set_pos

#define dir_set_pos   rb_f_notimplement

Definition at line 725 of file dir.c.

Referenced by Init_Dir().

◆ dir_tell

#define dir_tell   rb_f_notimplement

Definition at line 671 of file dir.c.

Referenced by Init_Dir().

◆ dirent

#define dirent   direct

Definition at line 32 of file dir.c.

Referenced by dir_each(), dir_read(), and glob_helper().

◆ do_lstat

#define do_lstat   do_stat

Definition at line 1064 of file dir.c.

Referenced by glob_helper().

◆ FNM_CASEFOLD

#define FNM_CASEFOLD   0x08

Definition at line 116 of file dir.c.

Referenced by bracket(), fnmatch_helper(), has_magic(), and Init_Dir().

◆ FNM_DOTMATCH

#define FNM_DOTMATCH   0x04

Definition at line 115 of file dir.c.

Referenced by fnmatch(), fnmatch_helper(), glob_helper(), and Init_Dir().

◆ FNM_ERROR

#define FNM_ERROR   2

Definition at line 125 of file dir.c.

◆ FNM_EXTGLOB

#define FNM_EXTGLOB   0x10

Definition at line 117 of file dir.c.

Referenced by file_s_fnmatch(), and Init_Dir().

◆ FNM_NOESCAPE

#define FNM_NOESCAPE   0x01

◆ FNM_NOMATCH

#define FNM_NOMATCH   1

Definition at line 124 of file dir.c.

Referenced by fnmatch(), fnmatch_brace(), and fnmatch_helper().

◆ FNM_PATHNAME

#define FNM_PATHNAME   0x02

Definition at line 114 of file dir.c.

Referenced by fnmatch(), fnmatch_helper(), and Init_Dir().

◆ FNM_SYSCASE

#define FNM_SYSCASE   0

Definition at line 121 of file dir.c.

Referenced by has_magic(), Init_Dir(), rb_glob2(), and ruby_glob0().

◆ GetDIR

#define GetDIR (   obj,
  dirp 
)    ((dirp) = dir_check(obj))

Definition at line 516 of file dir.c.

Referenced by dir_close(), dir_each(), dir_read(), and dir_rewind().

◆ GLOB_ALLOC

#define GLOB_ALLOC (   type)    ((type *)malloc(sizeof(type)))

Definition at line 1024 of file dir.c.

Referenced by glob_make_pattern().

◆ GLOB_ALLOC_N

#define GLOB_ALLOC_N (   type,
 
)    ((type *)malloc(sizeof(type) * (n)))

Definition at line 1025 of file dir.c.

Referenced by glob_helper(), glob_make_pattern(), join_path(), ruby_brace_expand(), and ruby_glob0().

◆ glob_call_func

#define glob_call_func (   func,
  path,
  arg,
  enc 
)    (*(func))((path), (arg), (enc))

Definition at line 1316 of file dir.c.

Referenced by glob_helper().

◆ GLOB_FREE

#define GLOB_FREE (   ptr)    free(ptr)

◆ GLOB_JUMP_TAG

#define GLOB_JUMP_TAG (   status)    (((status) == -1) ? rb_memerror() : rb_jump_tag(status))

Definition at line 1027 of file dir.c.

Referenced by dir_globs(), rb_glob(), and rb_push_glob().

◆ GLOB_VERBOSE

#define GLOB_VERBOSE   (1U << (sizeof(int) * CHAR_BIT - 1))

Definition at line 1020 of file dir.c.

Referenced by push_glob(), rb_glob2(), ruby_brace_glob(), ruby_brace_glob_with_enc(), and ruby_glob().

◆ GlobPathValue

#define GlobPathValue (   str,
  safe 
)
Value:
/* can contain null bytes as separators */ \
(!RB_TYPE_P((str), T_STRING) ? \
(void)FilePathValue(str) : \
(void)(check_safe_glob((str), (safe)), \
check_glob_encoding(str), (str)))
#define FilePathValue(v)
Definition: ruby.h:560
#define RB_TYPE_P(obj, type)
Definition: ruby.h:1672
#define T_STRING
Definition: ruby.h:482
#define check_safe_glob(str, safe)
Definition: dir.c:395

Definition at line 389 of file dir.c.

Referenced by dir_globs(), dir_initialize(), and rb_push_glob().

◆ HAVE_HFS

#define HAVE_HFS   0

Definition at line 81 of file dir.c.

◆ IF_HAVE_HFS

#define IF_HAVE_HFS (   something)    /* nothing */

Definition at line 110 of file dir.c.

Referenced by dir_each(), and glob_helper().

◆ Inc

#define Inc (   p,
  e,
  enc 
)    ((p) = Next((p), (e), (enc)))

Definition at line 128 of file dir.c.

Referenced by fnmatch(), fnmatch_helper(), remove_backslashes(), and ruby_brace_expand().

◆ ISEND

#define ISEND (   p)    (!*(p) || (pathname && *(p) == '/'))

Definition at line 205 of file dir.c.

Referenced by fnmatch_helper().

◆ NAMLEN

#define NAMLEN (   dirent)    (dirent)->d_namlen

Definition at line 33 of file dir.c.

Referenced by dir_each(), dir_read(), and glob_helper().

◆ Next

#define Next (   p,
  e,
  enc 
)    ((p)+ rb_enc_mbclen((p), (e), (enc)))

Definition at line 127 of file dir.c.

Referenced by find_dirsep(), and has_magic().

◆ READDIR

#define READDIR (   dir,
  enc 
)    readdir((dir))

Definition at line 565 of file dir.c.

Referenced by dir_each(), dir_read(), and glob_helper().

◆ RETURN

#define RETURN (   val)    return *pcur = p, *scur = s, (val);

Definition at line 206 of file dir.c.

Referenced by fnmatch_helper(), get_event_id(), and symbol2event_flag().

◆ S_ISDIR

#define S_ISDIR (   m)    (((m) & S_IFMT) == S_IFDIR)

Definition at line 1289 of file dir.c.

Referenced by glob_helper(), and load_file_internal().

◆ S_ISLNK

#define S_ISLNK (   m)    (0)

◆ STAT

#define STAT (   p,
 
)    stat((p), (s))

Definition at line 1038 of file dir.c.

Referenced by do_stat().

◆ sys_warning

#define sys_warning (   val)    (void)((flags & GLOB_VERBOSE) && rb_protect(sys_warning_1, (VALUE)(val), 0))

Definition at line 1021 of file dir.c.

Referenced by do_opendir(), and do_stat().

◆ to_be_ignored

#define to_be_ignored (   e)    ((e) == ENOENT || (e) == ENOTDIR)

Definition at line 1033 of file dir.c.

Referenced by do_opendir(), and do_stat().

◆ UNESCAPE

#define UNESCAPE (   p)    (escape && *(p) == '\\' ? (p) + 1 : (p))

Definition at line 204 of file dir.c.

Referenced by fnmatch_helper().

Enumeration Type Documentation

◆ answer

enum answer
Enumerator
UNKNOWN 
NO 
YES 

Definition at line 1286 of file dir.c.

◆ glob_pattern_type

Enumerator
PLAIN 
MAGICAL 
RECURSIVE 
MATCH_ALL 
MATCH_DIR 

Definition at line 1182 of file dir.c.

Function Documentation

◆ bracket()

static char* bracket ( const char *  p,
const char *  pend,
const char *  s,
const char *  send,
int  flags,
rb_encoding enc 
)
static

Definition at line 131 of file dir.c.

References FNM_CASEFOLD, FNM_NOESCAPE, memcmp(), NULL, rb_enc_codepoint, rb_enc_mbclen(), and rb_enc_toupper().

Referenced by fnmatch_helper().

◆ chdir_restore()

static VALUE chdir_restore ( struct chdir_data args)
static

Definition at line 798 of file dir.c.

References chdir_blocking, chdir_thread, dir_chdir(), chdir_data::done, chdir_data::old_path, and Qnil.

Referenced by dir_s_chdir().

◆ chdir_yield()

static VALUE chdir_yield ( struct chdir_data args)
static

◆ check_dirname()

static void check_dirname ( volatile VALUE dir)
static

◆ dir_chdir()

static void dir_chdir ( VALUE  path)
static

Definition at line 772 of file dir.c.

References dir_data::path, rb_sys_fail_path, and RSTRING_PTR.

Referenced by chdir_restore(), chdir_yield(), and dir_s_chdir().

◆ dir_check()

static struct dir_data* dir_check ( VALUE  dir)
static

Definition at line 507 of file dir.c.

References dir_data::dir, dir_closed(), dir_data_type, rb_check_frozen, and rb_check_typeddata().

◆ dir_close()

static VALUE dir_close ( VALUE  dir)
static

Definition at line 760 of file dir.c.

References closedir, dir_data::dir, GetDIR, NULL, and Qnil.

Referenced by dir_entries(), dir_foreach(), dir_s_open(), and Init_Dir().

◆ dir_closed()

static void dir_closed ( void  )
static

Definition at line 501 of file dir.c.

References rb_eIOError, and rb_raise().

Referenced by dir_check(), and dir_each().

◆ dir_each()

static VALUE dir_each ( VALUE  dir)
static

◆ dir_entries()

static VALUE dir_entries ( int  argc,
VALUE argv,
VALUE  io 
)
static

Definition at line 1963 of file dir.c.

References argc, argv, dir_close(), dir_open_dir(), rb_Array(), and rb_ensure().

Referenced by Init_Dir().

◆ dir_foreach()

static VALUE dir_foreach ( int  argc,
VALUE argv,
VALUE  io 
)
static

Definition at line 1937 of file dir.c.

References argc, argv, dir_close(), dir_each(), dir_open_dir(), Qnil, rb_ensure(), and RETURN_ENUMERATOR.

Referenced by Init_Dir().

◆ dir_free()

static void dir_free ( void *  ptr)
static

Definition at line 366 of file dir.c.

References closedir, dir_data::dir, and xfree().

◆ dir_globs()

static VALUE dir_globs ( long  argc,
const VALUE argv,
int  flags 
)
static

Definition at line 1769 of file dir.c.

References argc, argv, GLOB_JUMP_TAG, GlobPathValue, push_glob(), rb_ary_new(), and TRUE.

Referenced by dir_s_aref(), and dir_s_glob().

◆ dir_initialize()

static VALUE dir_initialize ( int  argc,
VALUE argv,
VALUE  dir 
)
static

◆ dir_inspect()

static VALUE dir_inspect ( VALUE  dir)
static

◆ dir_mark()

static void dir_mark ( void *  ptr)
static

Definition at line 359 of file dir.c.

References dir_data::dir, and rb_gc_mark().

◆ dir_memsize()

static size_t dir_memsize ( const void *  ptr)
static

Definition at line 376 of file dir.c.

◆ dir_open_dir()

static VALUE dir_open_dir ( int  argc,
VALUE argv 
)
static

Definition at line 1905 of file dir.c.

References argc, argv, dir_data_type, rb_cDir, rb_check_typeddata(), rb_funcall2, and rb_intern.

Referenced by dir_entries(), and dir_foreach().

◆ dir_path()

static VALUE dir_path ( VALUE  dir)
static

Definition at line 553 of file dir.c.

References dir_data::dir, dir_data_type, NIL_P, dir_data::path, Qnil, rb_str_dup(), and TypedData_Get_Struct.

Referenced by Init_Dir().

◆ dir_read()

static VALUE dir_read ( VALUE  dir)
static

Definition at line 581 of file dir.c.

References dir_data::dir, dirent, dp, dir_data::enc, errno, GetDIR, NAMLEN, NULL, Qnil, rb_external_str_new_with_enc(), rb_sys_fail(), and READDIR.

Referenced by Init_Dir().

◆ dir_rewind()

static VALUE dir_rewind ( VALUE  dir)
static

Definition at line 740 of file dir.c.

References dir_data::dir, GetDIR, and rewinddir().

Referenced by Init_Dir().

◆ dir_s_alloc()

static VALUE dir_s_alloc ( VALUE  klass)
static

Definition at line 399 of file dir.c.

References dir_data::dir, dir_data_type, dir_data::enc, NULL, dir_data::path, Qnil, and TypedData_Make_Struct.

Referenced by Init_Dir().

◆ dir_s_aref()

static VALUE dir_s_aref ( int  argc,
VALUE argv,
VALUE  obj 
)
static

Definition at line 1794 of file dir.c.

References argc, argv, dir_globs(), and rb_push_glob().

Referenced by Init_Dir().

◆ dir_s_chdir()

static VALUE dir_s_chdir ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ dir_s_getwd()

static VALUE dir_s_getwd ( VALUE  dir)
static

Definition at line 911 of file dir.c.

References rb_dir_getwd().

Referenced by Init_Dir().

◆ dir_s_glob()

static VALUE dir_s_glob ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ dir_s_home()

static VALUE dir_s_home ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ dir_s_mkdir()

static VALUE dir_s_mkdir ( int  argc,
VALUE argv,
VALUE  obj 
)
static

Definition at line 975 of file dir.c.

References argc, argv, check_dirname(), INT2FIX, NUM2INT, rb_scan_args(), rb_sys_fail_path, and RSTRING_PTR.

Referenced by Init_Dir().

◆ dir_s_open()

static VALUE dir_s_open ( int  argc,
VALUE argv,
VALUE  klass 
)
static

◆ dir_s_rmdir()

static VALUE dir_s_rmdir ( VALUE  obj,
VALUE  dir 
)
static

Definition at line 1004 of file dir.c.

References check_dirname(), INT2FIX, rb_sys_fail_path, and RSTRING_PTR.

Referenced by Init_Dir().

◆ do_opendir()

static DIR* do_opendir ( const char *  path,
int  flags,
rb_encoding enc 
)
static

◆ do_stat()

static int do_stat ( const char *  path,
struct stat pst,
int  flags 
)
static

Definition at line 1043 of file dir.c.

References errno, STAT, sys_warning, and to_be_ignored.

Referenced by glob_helper().

◆ file_s_fnmatch()

static VALUE file_s_fnmatch ( int  argc,
VALUE argv,
VALUE  obj 
)
static

◆ find_dirsep()

static char* find_dirsep ( const char *  p,
const char *  pend,
int  flags,
rb_encoding enc 
)
static

Definition at line 1122 of file dir.c.

References FNM_NOESCAPE, and Next.

Referenced by glob_make_pattern().

◆ fnmatch()

static int fnmatch ( const char *  pattern,
rb_encoding enc,
const char *  string,
int  flags 
)
static

Definition at line 301 of file dir.c.

References FNM_DOTMATCH, FNM_NOMATCH, FNM_PATHNAME, fnmatch_helper(), Inc, and strlen().

Referenced by file_s_fnmatch(), fnmatch_brace(), and glob_helper().

◆ fnmatch_brace()

static int fnmatch_brace ( const char *  pattern,
VALUE  val,
void *  enc 
)
static

◆ fnmatch_helper()

static int fnmatch_helper ( const char **  pcur,
const char **  scur,
int  flags,
rb_encoding enc 
)
static

◆ getenv()

char* getenv ( )

Referenced by dir_s_chdir().

◆ glob_brace()

static int glob_brace ( const char *  path,
VALUE  val,
void *  enc 
)
static

Definition at line 1693 of file dir.c.

References brace_args::flags, brace_args::func, ruby_glob0(), val, and brace_args::value.

Referenced by ruby_brace_glob0().

◆ glob_free_pattern()

static void glob_free_pattern ( struct glob_pattern list)
static

Definition at line 1260 of file dir.c.

References GLOB_FREE, list, and glob_pattern::str.

Referenced by glob_make_pattern(), and ruby_glob0().

◆ glob_func_caller()

static VALUE glob_func_caller ( VALUE  val)
static

Definition at line 1308 of file dir.c.

References glob_args::enc, glob_args::func, glob_args::path, Qnil, val, and glob_args::value.

Referenced by rb_glob_caller().

◆ glob_helper()

static int glob_helper ( const char *  path,
int  dirsep,
enum answer  exist,
enum answer  isdir,
struct glob_pattern **  beg,
struct glob_pattern **  end,
int  flags,
ruby_glob_func func,
VALUE  arg,
rb_encoding enc 
)
static

◆ glob_make_pattern()

static struct glob_pattern* glob_make_pattern ( const char *  p,
const char *  e,
int  flags,
rb_encoding enc 
)
static

◆ has_magic()

static int has_magic ( const char *  p,
const char *  pend,
int  flags,
rb_encoding enc 
)
static

Definition at line 1090 of file dir.c.

References FNM_CASEFOLD, FNM_NOESCAPE, FNM_SYSCASE, ISALPHA, and Next.

Referenced by glob_make_pattern().

◆ Init_Dir()

void Init_Dir ( void  )

◆ join_path()

static char* join_path ( const char *  path,
long  len,
int  dirsep,
const char *  name,
size_t  namlen 
)
static

Definition at line 1272 of file dir.c.

References buf, GLOB_ALLOC_N, and name.

Referenced by glob_helper().

◆ push_glob()

static int push_glob ( VALUE  ary,
VALUE  str,
int  flags 
)
static

◆ push_pattern()

static void push_pattern ( const char *  path,
VALUE  ary,
void *  enc 
)
static

Definition at line 1622 of file dir.c.

References glob_args::enc, glob_args::path, rb_ary_push(), rb_external_str_new_with_enc(), and strlen().

Referenced by push_glob().

◆ rb_dir_exists_p()

static VALUE rb_dir_exists_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 2170 of file dir.c.

References rb_file_directory_p(), and rb_warning().

Referenced by Init_Dir().

◆ rb_dir_getwd()

VALUE rb_dir_getwd ( void  )

◆ rb_glob()

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

Definition at line 1615 of file dir.c.

References func, GLOB_JUMP_TAG, glob_args::path, rb_ascii8bit_encoding(), and rb_glob2().

◆ rb_glob2()

static int rb_glob2 ( const char *  path,
int  flags,
void(*)(const char *, VALUE, void *)  func,
VALUE  arg,
rb_encoding enc 
)
static

◆ rb_glob_caller()

static int rb_glob_caller ( const char *  path,
VALUE  a,
void *  enc 
)
static

Definition at line 1585 of file dir.c.

References glob_func_caller(), glob_args::path, and rb_protect().

Referenced by push_glob(), and rb_glob2().

◆ rb_push_glob()

static VALUE rb_push_glob ( VALUE  str,
int  flags 
)
static

◆ remove_backslashes()

static char* remove_backslashes ( char *  p,
register const char *  pend,
rb_encoding enc 
)
static

Definition at line 1157 of file dir.c.

References Inc, memmove(), and t().

Referenced by glob_helper().

◆ ruby_brace_expand()

static int ruby_brace_expand ( const char *  str,
int  flags,
ruby_glob_func func,
VALUE  arg,
rb_encoding enc 
)
static

Definition at line 1628 of file dir.c.

References buf, glob_args::enc, FNM_NOESCAPE, func, GLOB_ALLOC_N, GLOB_FREE, Inc, shift(), strlcpy(), strlen(), and t().

Referenced by file_s_fnmatch(), and ruby_brace_glob0().

◆ ruby_brace_glob()

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

Definition at line 1713 of file dir.c.

References brace_args::flags, func, GLOB_VERBOSE, rb_ascii8bit_encoding(), and ruby_brace_glob0().

Referenced by cmdglob().

◆ ruby_brace_glob0()

static int ruby_brace_glob0 ( const char *  str,
int  flags,
ruby_glob_func func,
VALUE  arg,
rb_encoding enc 
)
static

◆ ruby_brace_glob_with_enc()

int ruby_brace_glob_with_enc ( const char *  str,
int  flags,
ruby_glob_func func,
VALUE  arg,
rb_encoding enc 
)

Definition at line 1720 of file dir.c.

References brace_args::flags, func, GLOB_VERBOSE, and ruby_brace_glob0().

◆ ruby_glob()

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

Definition at line 1578 of file dir.c.

References func, GLOB_VERBOSE, rb_ascii8bit_encoding(), and ruby_glob0().

◆ ruby_glob0()

static int ruby_glob0 ( const char *  path,
int  flags,
ruby_glob_func func,
VALUE  arg,
rb_encoding enc 
)
static

◆ strchr()

char* strchr ( char *  ,
char   
)

◆ sys_warning_1()

static VALUE sys_warning_1 ( VALUE  mesg)
static

Definition at line 1014 of file dir.c.

References errno, Qnil, rb_sys_warning(), and strerror().

Variable Documentation

◆ chdir_blocking

int chdir_blocking = 0
static

Definition at line 778 of file dir.c.

Referenced by chdir_restore(), chdir_yield(), and dir_s_chdir().

◆ chdir_thread

VALUE chdir_thread = Qnil
static

Definition at line 779 of file dir.c.

Referenced by chdir_restore(), chdir_yield(), and dir_s_chdir().

◆ dir_data_type

const rb_data_type_t dir_data_type
static
Initial value:
= {
"dir",
}
static void dir_free(void *ptr)
Definition: dir.c:366
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1015
static size_t dir_memsize(const void *ptr)
Definition: dir.c:376
static void dir_mark(void *ptr)
Definition: dir.c:359
#define NULL
Definition: _sdbm.c:102

Definition at line 381 of file dir.c.

Referenced by dir_check(), dir_initialize(), dir_inspect(), dir_open_dir(), dir_path(), dir_s_alloc(), and dir_s_open().

◆ rb_cDir

VALUE rb_cDir