Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Enumerations | Functions | Variables
dir.c File Reference
#include "internal.h"
#include "encindex.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <ctype.h>
#include "ruby/util.h"
Include dependency graph for dir.c:

Go to the source code of this file.

Data Structures

struct  dir_data
 
struct  chdir_data
 
struct  warning_args
 
struct  glob_pattern
 
struct  glob_args
 
struct  brace_args
 
struct  push_glob_args
 

Macros

#define dirent   direct
 
#define NAMLEN(dirent)   (dirent)->d_namlen
 
#define HAVE_DIRENT_NAMLEN   1
 
#define IS_WIN32   0
 
#define USE_NAME_ON_FS_REAL_BASENAME
 
#define USE_NAME_ON_FS_BY_FNMATCH
 
#define USE_NAME_ON_FS   0
 
#define NORMALIZE_UTF8PATH   0
 
#define IF_NORMALIZE_UTF8PATH(something)   /* nothing */
 
#define IFTODT(m)   (((m) & S_IFMT) / ((~S_IFMT & S_IFMT-1) + 1))
 
#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_SHORTNAME   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 dir_fileno   rb_f_notimplement
 
#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 sys_enc_warning_in(func, mesg, enc)   sys_enc_warning(mesg, enc)
 
#define GLOB_VERBOSE   (1U << (sizeof(int) * CHAR_BIT - 1))
 
#define sys_warning(val, enc)   ((flags & GLOB_VERBOSE) ? sys_enc_warning_in(RUBY_FUNCTION_NAME_STRING, (val), (enc)) :(void)0)
 
#define GLOB_ALLOC(type)   ((type *)malloc(sizeof(type)))
 
#define GLOB_ALLOC_N(type, n)   ((type *)malloc(sizeof(type) * (n)))
 
#define GLOB_REALLOC(ptr, size)   realloc((ptr), (size))
 
#define GLOB_FREE(ptr)   free(ptr)
 
#define GLOB_JUMP_TAG(status)   (((status) == -1) ? rb_memerror() : rb_jump_tag(status))
 
#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), (void *)(enc))
 

Enumerations

enum  rb_pathtype_t {
  path_exist, path_directory = IFTODT(S_IFDIR), path_regular = IFTODT(S_IFREG), path_symlink = IFTODT(S_IFLNK),
  path_noent = -1, path_unknown = -2
}
 
enum  glob_pattern_type {
  PLAIN, ALPHA, MAGICAL, RECURSIVE,
  MATCH_ALL, MATCH_DIR
}
 

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_get (VALUE dir)
 
static struct dir_datadir_check (VALUE dir)
 
static VALUE dir_inspect (VALUE dir)
 
static VALUE dir_path (VALUE dir)
 
static int to_be_skipped (const struct dirent *dp)
 
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 VALUE check_dirname (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 void sys_enc_warning_in (const char *func, const char *mesg, rb_encoding *enc)
 
 ALWAYS_INLINE (static int to_be_ignored(int e))
 
static int to_be_ignored (int e)
 
static int do_stat (const char *path, struct stat *pst, int flags, rb_encoding *enc)
 
static DIRdo_opendir (const char *path, int flags, rb_encoding *enc)
 
static enum glob_pattern_type 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 dirent_match (const char *pat, rb_encoding *enc, const char *name, const struct dirent *dp, int flags)
 
static int glob_helper (const char *path, long pathlen, int dirsep, rb_pathtype_t pathtype, 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)
 
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)
 
int ruby_brace_glob_with_enc (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)
 
static int push_caller (const char *path, VALUE val, void *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)
 
static VALUE rb_dir_s_empty_p (VALUE obj, VALUE dirname)
 
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 466 of file dir.c.

◆ check_safe_glob

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

Definition at line 465 of file dir.c.

◆ dir_fileno

#define dir_fileno   rb_f_notimplement

Definition at line 670 of file dir.c.

Referenced by dir_inspect(), and Init_Dir().

◆ dir_s_chroot

#define dir_s_chroot   rb_f_notimplement

Definition at line 1129 of file dir.c.

Referenced by check_dirname(), and Init_Dir().

◆ dir_seek

#define dir_seek   rb_f_notimplement

Definition at line 865 of file dir.c.

Referenced by Init_Dir().

◆ dir_set_pos

#define dir_set_pos   rb_f_notimplement

Definition at line 890 of file dir.c.

Referenced by Init_Dir().

◆ dir_tell

#define dir_tell   rb_f_notimplement

Definition at line 836 of file dir.c.

Referenced by dir_each(), and Init_Dir().

◆ dirent

#define dirent   direct

Definition at line 32 of file dir.c.

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

◆ do_lstat

#define do_lstat   do_stat

Definition at line 1273 of file dir.c.

Referenced by do_stat(), and glob_helper().

◆ FNM_CASEFOLD

#define FNM_CASEFOLD   0x08

Definition at line 181 of file dir.c.

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

◆ FNM_DOTMATCH

#define FNM_DOTMATCH   0x04

Definition at line 180 of file dir.c.

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

◆ FNM_ERROR

#define FNM_ERROR   2

Definition at line 195 of file dir.c.

◆ FNM_EXTGLOB

#define FNM_EXTGLOB   0x10

Definition at line 182 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 194 of file dir.c.

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

◆ FNM_PATHNAME

#define FNM_PATHNAME   0x02

Definition at line 179 of file dir.c.

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

◆ FNM_SHORTNAME

#define FNM_SHORTNAME   0

Definition at line 191 of file dir.c.

Referenced by dirent_match(), and Init_Dir().

◆ FNM_SYSCASE

#define FNM_SYSCASE   0

Definition at line 186 of file dir.c.

Referenced by glob_make_pattern(), Init_Dir(), and ruby_glob0().

◆ GetDIR

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

Definition at line 603 of file dir.c.

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

◆ GLOB_ALLOC

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

Definition at line 1226 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 1227 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), (void *)(enc))

Definition at line 1697 of file dir.c.

Referenced by glob_func_caller(), glob_helper(), and ruby_brace_expand().

◆ 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 1230 of file dir.c.

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

◆ GLOB_REALLOC

#define GLOB_REALLOC (   ptr,
  size 
)    realloc((ptr), (size))

Definition at line 1228 of file dir.c.

Referenced by join_path().

◆ GLOB_VERBOSE

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

Definition at line 1222 of file dir.c.

Referenced by push_glob(), rb_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:594
#define RB_TYPE_P(obj, type)
Definition: ruby.h:527
#define T_STRING
Definition: ruby.h:496
#define check_safe_glob(str, safe)
Definition: dir.c:465

Definition at line 459 of file dir.c.

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

◆ HAVE_DIRENT_NAMLEN

#define HAVE_DIRENT_NAMLEN   1

Definition at line 34 of file dir.c.

◆ IF_NORMALIZE_UTF8PATH

#define IF_NORMALIZE_UTF8PATH (   something)    /* nothing */

Definition at line 155 of file dir.c.

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

◆ IFTODT

#define IFTODT (   m)    (((m) & S_IFMT) / ((~S_IFMT & S_IFMT-1) + 1))

Definition at line 159 of file dir.c.

Referenced by glob_helper().

◆ Inc

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

Definition at line 198 of file dir.c.

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

◆ IS_WIN32

#define IS_WIN32   0

Definition at line 79 of file dir.c.

Referenced by has_magic().

◆ ISEND

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

Definition at line 275 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(), glob_helper(), and to_be_skipped().

◆ Next

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

Definition at line 197 of file dir.c.

Referenced by find_dirsep(), has_magic(), and sock_s_unpack_sockaddr_in().

◆ NORMALIZE_UTF8PATH

#define NORMALIZE_UTF8PATH   0

Definition at line 106 of file dir.c.

◆ READDIR

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

Definition at line 708 of file dir.c.

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

◆ RETURN

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

Definition at line 276 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 1679 of file dir.c.

◆ S_ISLNK

#define S_ISLNK (   m)    (0)

◆ STAT

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

Definition at line 1248 of file dir.c.

Referenced by do_stat().

◆ sys_enc_warning_in

#define sys_enc_warning_in (   func,
  mesg,
  enc 
)    sys_enc_warning(mesg, enc)

Definition at line 1195 of file dir.c.

◆ sys_warning

#define sys_warning (   val,
  enc 
)    ((flags & GLOB_VERBOSE) ? sys_enc_warning_in(RUBY_FUNCTION_NAME_STRING, (val), (enc)) :(void)0)

Definition at line 1223 of file dir.c.

Referenced by do_opendir(), do_stat(), and join_path().

◆ UNESCAPE

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

Definition at line 274 of file dir.c.

Referenced by fnmatch_helper().

◆ USE_NAME_ON_FS

#define USE_NAME_ON_FS   0

Definition at line 100 of file dir.c.

Referenced by glob_make_pattern().

◆ USE_NAME_ON_FS_BY_FNMATCH

#define USE_NAME_ON_FS_BY_FNMATCH
Value:
2 /* select the matching
* basename by fnmatch */

Definition at line 88 of file dir.c.

◆ USE_NAME_ON_FS_REAL_BASENAME

#define USE_NAME_ON_FS_REAL_BASENAME
Value:
1 /* platform dependent APIs to
* get real basenames */

Definition at line 86 of file dir.c.

Enumeration Type Documentation

◆ glob_pattern_type

Enumerator
PLAIN 
ALPHA 
MAGICAL 
RECURSIVE 
MATCH_ALL 
MATCH_DIR 

Definition at line 1310 of file dir.c.

◆ rb_pathtype_t

Enumerator
path_exist 
path_directory 
path_regular 
path_symlink 
path_noent 
path_unknown 

Definition at line 162 of file dir.c.

Function Documentation

◆ ALWAYS_INLINE()

ALWAYS_INLINE ( static int   to_be_ignoredint e)

◆ 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 201 of file dir.c.

References FNM_CASEFOLD, FNM_NOESCAPE, memcmp(), NULL, r2, 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 964 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 VALUE check_dirname ( VALUE  dir)
static

◆ dir_chdir()

static void dir_chdir ( VALUE  path)
static

Definition at line 938 of file dir.c.

References 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 596 of file dir.c.

References dir_data::dir, dir_closed(), and dir_get().

◆ dir_close()

static VALUE dir_close ( VALUE  dir)
static

Definition at line 925 of file dir.c.

References closedir, dir_data::dir, dir_get(), 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 583 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 2440 of file dir.c.

References dir_data::dir, 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 2414 of file dir.c.

References dir_data::dir, 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 436 of file dir.c.

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

◆ dir_get()

static struct dir_data* dir_get ( VALUE  dir)
static

Definition at line 589 of file dir.c.

References rb_check_frozen, and rb_check_typeddata().

Referenced by dir_check(), and dir_close().

◆ dir_globs()

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

Definition at line 2245 of file dir.c.

References argc, 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 429 of file dir.c.

References dir_data::dir, dir_data::path, and rb_gc_mark().

◆ dir_memsize()

static size_t dir_memsize ( const void *  ptr)
static

Definition at line 446 of file dir.c.

◆ dir_open_dir()

static VALUE dir_open_dir ( int  argc,
VALUE argv 
)
static

Definition at line 2382 of file dir.c.

References dir_data::dir, rb_cDir, rb_check_typeddata(), rb_funcallv, and rb_intern.

Referenced by dir_entries(), and dir_foreach().

◆ dir_path()

static VALUE dir_path ( VALUE  dir)
static

◆ dir_read()

static VALUE dir_read ( VALUE  dir)
static

◆ dir_rewind()

static VALUE dir_rewind ( VALUE  dir)
static

Definition at line 905 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 469 of file dir.c.

References dir_data::dir, 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 2270 of file dir.c.

References 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 1084 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 1148 of file dir.c.

References check_dirname(), INT2FIX, NUM2INT, dir_data::path, 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 1177 of file dir.c.

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

Referenced by Init_Dir().

◆ dirent_match()

static int dirent_match ( const char *  pat,
rb_encoding enc,
const char *  name,
const struct dirent dp,
int  flags 
)
inlinestatic

Definition at line 1709 of file dir.c.

References FNM_SHORTNAME, and fnmatch().

Referenced by glob_helper().

◆ 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,
rb_encoding enc 
)
static

Definition at line 1253 of file dir.c.

References do_lstat, errno, lstat(), dir_data::path, stat, 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 1356 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

◆ 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 2152 of file dir.c.

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

Referenced by ruby_brace_glob_with_enc().

◆ glob_free_pattern()

static void glob_free_pattern ( struct glob_pattern list)
static

Definition at line 1492 of file dir.c.

References GLOB_FREE, list, glob_pattern::next, 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 1700 of file dir.c.

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

Referenced by rb_glob_caller().

◆ glob_helper()

static int glob_helper ( const char *  path,
long  pathlen,
int  dirsep,
rb_pathtype_t  pathtype,
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 enum glob_pattern_type has_magic ( const char *  p,
const char *  pend,
int  flags,
rb_encoding enc 
)
static

Definition at line 1314 of file dir.c.

References ALPHA, FNM_NOESCAPE, IS_WIN32, ISALPHA, MAGICAL, Next, and PLAIN.

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

◆ push_caller()

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

Definition at line 2183 of file dir.c.

References push_glob_args::flags, push_glob_args::glob, rb_glob_caller(), and ruby_glob0().

Referenced by push_glob().

◆ 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

◆ rb_dir_exists_p()

static VALUE rb_dir_exists_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 2652 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_dir_s_empty_p()

static VALUE rb_dir_s_empty_p ( VALUE  obj,
VALUE  dirname 
)
static

◆ rb_glob()

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

◆ rb_glob_caller()

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

Definition at line 2047 of file dir.c.

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

Referenced by push_caller(), and rb_glob().

◆ 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 1391 of file dir.c.

References Inc, and memmove().

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

◆ ruby_brace_glob()

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

Definition at line 2172 of file dir.c.

References rb_ascii8bit_encoding(), and ruby_brace_glob_with_enc().

◆ 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 
)

◆ ruby_glob()

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

Definition at line 2040 of file dir.c.

References 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_enc_warning_in()

static void sys_enc_warning_in ( const char *  func,
const char *  mesg,
rb_encoding enc 
)
static

◆ sys_warning_1()

static VALUE sys_warning_1 ( VALUE  mesg)
static

Definition at line 1199 of file dir.c.

References warning_args::enc, warning_args::mesg, Qnil, and rb_sys_enc_warning().

Referenced by sys_enc_warning_in().

◆ to_be_ignored()

static int to_be_ignored ( int  e)
inlinestatic

Definition at line 1238 of file dir.c.

Referenced by do_opendir(), do_stat(), and join_path().

◆ to_be_skipped()

static int to_be_skipped ( const struct dirent dp)
static

Definition at line 711 of file dir.c.

References FALSE, name, NAMLEN, and TRUE.

Referenced by rb_dir_s_empty_p().

Variable Documentation

◆ chdir_blocking

int chdir_blocking = 0
static

Definition at line 944 of file dir.c.

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

◆ chdir_thread

VALUE chdir_thread = Qnil
static

Definition at line 945 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:436
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static size_t dir_memsize(const void *ptr)
Definition: dir.c:446
static void dir_mark(void *ptr)
Definition: dir.c:429

Definition at line 451 of file dir.c.

◆ rb_cDir

VALUE rb_cDir