17 #include <sys/types.h> 24 #undef HAVE_DIRENT_NAMLEN 25 #if defined HAVE_DIRENT_H && !defined _WIN32 27 # define NAMLEN(dirent) strlen((dirent)->d_name) 28 #elif defined HAVE_DIRECT_H && !defined _WIN32 30 # define NAMLEN(dirent) strlen((dirent)->d_name) 32 # define dirent direct 33 # define NAMLEN(dirent) (dirent)->d_namlen 34 # define HAVE_DIRENT_NAMLEN 1 36 # include <sys/ndir.h> 48 #if defined(__native_client__) && defined(NACL_NEWLIB) 70 #define chdir(p) rb_w32_uchdir(p) 72 #define mkdir(p, m) rb_w32_umkdir((p), (m)) 74 #define rmdir(p) rb_w32_urmdir(p) 76 #define opendir(p) rb_w32_uopendir(p) 82 #ifdef HAVE_SYS_ATTR_H 86 #define USE_NAME_ON_FS_REAL_BASENAME 1 88 #define USE_NAME_ON_FS_BY_FNMATCH 2 91 #ifdef HAVE_GETATTRLIST 92 # define USE_NAME_ON_FS USE_NAME_ON_FS_REAL_BASENAME 93 # define RUP32(size) ((size)+3/4) 94 # define SIZEUP32(type) RUP32(sizeof(type)) 96 # define USE_NAME_ON_FS USE_NAME_ON_FS_REAL_BASENAME 98 # define USE_NAME_ON_FS USE_NAME_ON_FS_BY_FNMATCH 100 # define USE_NAME_ON_FS 0 104 # define NORMALIZE_UTF8PATH 1 106 # define NORMALIZE_UTF8PATH 0 109 #if NORMALIZE_UTF8PATH 110 #include <sys/param.h> 111 #include <sys/mount.h> 112 #include <sys/vnode.h> 114 # if defined HAVE_FGETATTRLIST || !defined HAVE_GETATTRLIST 115 # define need_normalization(dirp, path) need_normalization(dirp) 117 # define need_normalization(dirp, path) need_normalization(path) 120 need_normalization(
DIR *dirp,
const char *path)
122 # if defined HAVE_FGETATTRLIST || defined HAVE_GETATTRLIST 123 u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)];
124 struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,};
125 # if defined HAVE_FGETATTRLIST 126 int ret = fgetattrlist(dirfd(dirp), &al, attrbuf,
sizeof(attrbuf), 0);
128 int ret = getattrlist(path, &al, attrbuf,
sizeof(attrbuf), 0);
131 const fsobj_tag_t *tag = (
void *)(attrbuf+1);
143 has_nonascii(
const char *ptr,
size_t len)
153 # define IF_NORMALIZE_UTF8PATH(something) something 155 # define IF_NORMALIZE_UTF8PATH(something) 159 # define IFTODT(m) (((m) & S_IFMT) / ((~S_IFMT & S_IFMT-1) + 1)) 178 #define FNM_NOESCAPE 0x01 179 #define FNM_PATHNAME 0x02 180 #define FNM_DOTMATCH 0x04 181 #define FNM_CASEFOLD 0x08 182 #define FNM_EXTGLOB 0x10 183 #if CASEFOLD_FILESYSTEM 184 #define FNM_SYSCASE FNM_CASEFOLD 186 #define FNM_SYSCASE 0 189 #define FNM_SHORTNAME 0x20 191 #define FNM_SHORTNAME 0 194 #define FNM_NOMATCH 1 197 # define Next(p, e, enc) ((p)+ rb_enc_mbclen((p), (e), (enc))) 198 # define Inc(p, e, enc) ((p) = Next((p), (e), (enc))) 215 if (p >= pend)
return NULL;
216 if (*p ==
'!' || *p ==
'^') {
223 if (escape && *t1 ==
'\\')
228 if (p >= pend)
return NULL;
229 if (p[0] ==
'-' && p[1] !=
']') {
230 const char *t2 = p + 1;
232 if (escape && *t2 ==
'\\')
238 if ((r <= (send-s) &&
memcmp(t1, s, r) == 0) ||
239 (r2 <= (send-s) &&
memcmp(t2, s, r2) == 0)) {
247 if (c1 < c2)
continue;
250 if (c1 > c2)
continue;
254 if (r <= (send-s) &&
memcmp(t1, s, r) == 0) {
258 if (!nocase)
continue;
261 if (c1 != c2)
continue;
266 return ok == not ?
NULL : (
char *)p + 1;
274 #define UNESCAPE(p) (escape && *(p) == '\\' ? (p) + 1 : (p)) 275 #define ISEND(p) (!*(p) || (pathname && *(p) == '/')) 276 #define RETURN(val) return *pcur = p, *scur = s, (val); 290 const char *ptmp = 0;
291 const char *stmp = 0;
293 const char *p = *pcur;
294 const char *pend = p +
strlen(p);
295 const char *s = *scur;
296 const char *send = s +
strlen(s);
300 if (period && *s ==
'.' && *
UNESCAPE(p) !=
'.')
306 do { p++; }
while (*p ==
'*');
328 if ((t =
bracket(p + 1, pend, s, send, flags, enc)) != 0) {
346 if (r <= (send-s) &&
memcmp(p, s, r) == 0) {
351 if (!nocase)
goto failed;
362 Inc(stmp, send, enc);
377 const char *p = pattern;
378 const char *s = string;
379 const char *send = s +
strlen(
string);
383 const char *ptmp = 0;
384 const char *stmp = 0;
388 if (p[0] ==
'*' && p[1] ==
'*' && p[2] ==
'/') {
389 do { p += 3; }
while (p[0] ==
'*' && p[1] ==
'*' && p[2] ==
'/');
394 while (*s && *s !=
'/')
Inc(s, send, enc);
404 if (ptmp && stmp && !(period && *stmp ==
'.')) {
405 while (*stmp && *stmp !=
'/')
Inc(stmp, send, enc);
459 #define GlobPathValue(str, safe) \ 461 (!RB_TYPE_P((str), T_STRING) ? \ 462 (void)FilePathValue(str) : \ 463 (void)(check_safe_glob((str), (safe)), \ 464 check_glob_encoding(str), (str))) 465 #define check_safe_glob(str, safe) ((safe) ? rb_check_safe_obj(str) : (void)0) 466 #define check_glob_encoding(str) rb_enc_check((str), rb_enc_from_encoding(rb_usascii_encoding())) 496 VALUE dirname, opt, orig;
497 static ID keyword_ids[1];
500 if (!keyword_ids[0]) {
533 #ifdef HAVE_GETATTRLIST 535 u_int32_t attrbuf[1];
536 struct attrlist al = {ATTR_BIT_MAP_COUNT, 0};
537 if (getattrlist(path, &al, attrbuf,
sizeof(attrbuf), FSOPT_NOFOLLOW) == 0) {
603 #define GetDIR(obj, dirp) ((dirp) = dir_check(obj)) 632 #if defined(__sun) && !defined(HAVE_DIRFD) 633 # if defined(HAVE_DIR_D_FD) 634 # define dirfd(x) ((x)->d_fd) 635 # define HAVE_DIRFD 1 636 # elif defined(HAVE_DIR_DD_FD) 637 # define dirfd(x) ((x)->dd_fd) 638 # define HAVE_DIRFD 1 664 fd = dirfd(dirp->
dir);
670 #define dir_fileno rb_f_notimplement 706 # define READDIR(dir, enc) rb_w32_readdir((dir), (enc)) 708 # define READDIR(dir, enc) readdir((dir)) 713 const char *
name = dp->d_name;
714 if (name[0] !=
'.')
return FALSE;
715 #ifdef HAVE_DIRENT_NAMLEN 718 if (name[1] !=
'.')
return FALSE;
725 if (!name[1])
return TRUE;
726 if (name[1] !=
'.')
return FALSE;
727 if (!name[2])
return TRUE;
794 const char *
name = dp->d_name;
795 size_t namlen =
NAMLEN(dp);
797 #if NORMALIZE_UTF8PATH 798 if (norm_p && has_nonascii(name, namlen) &&
799 !
NIL_P(path = rb_str_normalize_ospath(name, namlen))) {
836 #define dir_tell rb_f_notimplement 865 #define dir_seek rb_f_notimplement 890 #define dir_set_pos rb_f_notimplement 1024 const char *dist =
getenv(
"HOME");
1034 rb_warn(
"conflicting chdir during another chdir block");
1060 cwd = rb_str_normalize_ospath(path,
strlen(path));
1102 if (pend - path < len) {
1109 #if defined(HAVE_CHROOT) 1129 #define dir_s_chroot rb_f_notimplement 1153 if (
rb_scan_args(argc, argv,
"11", &path, &vmode) == 2) {
1187 #ifdef RUBY_FUNCTION_NAME_STRING 1194 #ifndef RUBY_FUNCTION_NAME_STRING 1195 #define sys_enc_warning_in(func, mesg, enc) sys_enc_warning(mesg, enc) 1202 #ifdef RUBY_FUNCTION_NAME_STRING 1214 #ifdef RUBY_FUNCTION_NAME_STRING 1222 #define GLOB_VERBOSE (1U << (sizeof(int) * CHAR_BIT - 1)) 1223 #define sys_warning(val, enc) \ 1224 ((flags & GLOB_VERBOSE) ? sys_enc_warning_in(RUBY_FUNCTION_NAME_STRING, (val), (enc)) :(void)0) 1226 #define GLOB_ALLOC(type) ((type *)malloc(sizeof(type))) 1227 #define GLOB_ALLOC_N(type, n) ((type *)malloc(sizeof(type) * (n))) 1228 #define GLOB_REALLOC(ptr, size) realloc((ptr), (size)) 1229 #define GLOB_FREE(ptr) free(ptr) 1230 #define GLOB_JUMP_TAG(status) (((status) == -1) ? rb_memerror() : rb_jump_tag(status)) 1240 return e == ENOENT || e == ENOTDIR;
1244 #define STAT(p, s) rb_w32_ustati64((p), (s)) 1246 #define lstat(p, s) rb_w32_ulstati64((p), (s)) 1248 #define STAT(p, s) stat((p), (s)) 1255 int ret =
STAT(path, pst);
1262 #if defined HAVE_LSTAT || defined lstat 1266 int ret =
lstat(path, pst);
1273 #define do_lstat do_stat 1282 if (!fundamental_encoding_p(enc)) {
1321 while (p < pend && (c = *p++) != 0) {
1329 if (escape && p++ >= pend)
1348 p =
Next(p-1, pend, enc);
1363 while ((c = *p++) != 0) {
1378 if (escape && !(c = *p++))
1383 p =
Next(p-1, pend, enc);
1430 while (p < e && *p) {
1432 if (!tmp)
goto error;
1433 if (p + 2 < e && p[0] ==
'*' && p[1] ==
'*' && p[2] ==
'/') {
1435 do { p += 3;
while (*p ==
'/') p++; }
while (p[0] ==
'*' && p[1] ==
'*' && p[2] ==
'/');
1447 if (!(
FNM_SYSCASE || magic > non_magic) && !recursive && *m) {
1513 memcpy(buf+len, name, namlen);
1514 buf[len+namlen] =
'\0';
1518 #ifdef HAVE_GETATTRLIST 1519 # if defined HAVE_FGETATTRLIST 1520 # define is_case_sensitive(dirp, path) is_case_sensitive(dirp) 1522 # define is_case_sensitive(dirp, path) is_case_sensitive(path) 1525 is_case_sensitive(
DIR *dirp,
const char *path)
1529 vol_capabilities_attr_t cap[1];
1531 struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, 0, ATTR_VOL_INFO|ATTR_VOL_CAPABILITIES};
1532 const vol_capabilities_attr_t *
const cap = attrbuf[0].cap;
1533 const int idx = VOL_CAPABILITIES_FORMAT;
1534 const uint32_t mask = VOL_CAP_FMT_CASE_SENSITIVE;
1536 # if defined HAVE_FGETATTRLIST 1537 if (fgetattrlist(dirfd(dirp), &al, attrbuf,
sizeof(attrbuf), FSOPT_NOFOLLOW))
1540 if (getattrlist(path, &al, attrbuf,
sizeof(attrbuf), FSOPT_NOFOLLOW))
1543 if (!(cap->valid[idx] & mask))
1545 return (cap->capabilities[idx] & mask) != 0;
1553 attrreference_t ref[1];
1554 fsobj_type_t objtype;
1557 struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_NAME|ATTR_CMN_OBJTYPE};
1558 const attrreference_t *
const ar = attrbuf[0].ref;
1565 if (getattrlist(path, &al, attrbuf,
sizeof(attrbuf), FSOPT_NOFOLLOW)) {
1571 switch (attrbuf[0].objtype) {
1577 name = (
char *)ar + ar->attr_dataoffset;
1578 len = (
long)ar->attr_length - 1;
1579 if (name + len > (
char *)attrbuf +
sizeof(attrbuf))
1582 # if NORMALIZE_UTF8PATH 1583 if (norm_p && has_nonascii(name, len)) {
1584 if (!
NIL_P(utf8str = rb_str_normalize_ospath(name, len))) {
1593 memcpy(path + base, name, len);
1594 path[base +
len] =
'\0';
1599 #elif defined _WIN32 1606 char *plainname =
path;
1607 volatile VALUE tmp = 0;
1608 WIN32_FIND_DATAW fd;
1609 WIN32_FILE_ATTRIBUTE_DATA fa;
1611 HANDLE h = INVALID_HANDLE_VALUE;
1614 if (!fundamental_encoding_p(enc)) {
1621 if (!wplain)
return path;
1622 if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa)) {
1623 h = FindFirstFileW(wplain, &fd);
1626 if (fa.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
1628 fa.dwFileAttributes &= ~FILE_ATTRIBUTE_REPARSE_POINT;
1631 if (h == INVALID_HANDLE_VALUE) {
1641 (fa.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) ?
path_symlink :
1642 (fa.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ?
path_directory :
1652 path[base + wlen] = 0;
1658 wlen = WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1,
NULL, 0,
NULL,
NULL);
1662 WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, utf8filename, wlen,
NULL,
NULL);
1666 memcpy(path + base, utf8filename, wlen);
1667 path[base + wlen] = 0;
1674 #elif USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME 1675 # error not implemented 1679 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 1684 # define S_ISLNK(m) (0) 1686 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 1697 #define glob_call_func(func, path, arg, enc) (*(func))((path), (arg), (void *)(enc)) 1711 if (
fnmatch(pat, enc, name, flags) == 0)
return 1;
1714 if (
fnmatch(pat, enc, dp->d_altname, flags) == 0)
return 1;
1736 int plain = 0, magical = 0, recursive = 0, match_all = 0, match_dir = 0;
1739 for (cur = beg; cur < end; ++cur) {
1750 #if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME 1766 rb_bug(
"continuous RECURSIVEs");
1772 if (
do_lstat(path, &st, flags, enc) == 0) {
1773 pathtype =
IFTODT(st.st_mode);
1780 if (
do_stat(path, &st, flags, enc) == 0) {
1781 pathtype =
IFTODT(st.st_mode);
1789 if (status)
return status;
1792 char *tmp =
join_path(path, pathlen, dirsep,
"", 0);
1793 if (!tmp)
return -1;
1796 if (status)
return status;
1802 if (magical || recursive) {
1805 # if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH 1806 char *plainname = 0;
1809 # if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH 1810 if (cur + 1 == end && (*cur)->
type <=
ALPHA) {
1811 plainname =
join_path(path, pathlen, dirsep, (*cur)->str,
strlen((*cur)->str));
1812 if (!plainname)
return -1;
1818 dirp =
do_opendir(*path ? path :
".", flags, enc);
1820 # if FNM_SYSCASE || NORMALIZE_UTF8PATH 1821 if ((magical < 2) && !recursive && (
errno == EACCES)) {
1830 # if NORMALIZE_UTF8PATH 1831 if (!(norm_p || magical || recursive)) {
1836 # ifdef HAVE_GETATTRLIST 1837 if (is_case_sensitive(dirp, path) == 0)
1848 if (recursive && dp->d_name[0] ==
'.') {
1850 if (!dp->d_name[1]) {
1855 else if (dp->d_name[1] ==
'.' && !dp->d_name[2]) {
1863 # if NORMALIZE_UTF8PATH 1864 if (norm_p && has_nonascii(name, namlen)) {
1865 if (!
NIL_P(utf8str = rb_str_normalize_ospath(name, namlen))) {
1870 buf =
join_path(path, pathlen, dirsep, name, namlen);
1876 name = buf + pathlen + (dirsep != 0);
1877 if (recursive && dotfile < ((flags &
FNM_DOTMATCH) ? 2 : 1)) {
1886 if (
do_lstat(buf, &st, flags, enc) == 0)
1887 new_pathtype =
IFTODT(st.st_mode);
1899 for (cur = beg; cur < end; ++cur) {
1909 # if USE_NAME_ON_FS == USE_NAME_ON_FS_BY_FNMATCH 1911 *new_end++ = p->
next;
1918 *new_end++ = p->
next;
1925 new_pathtype, new_beg, new_end,
1926 flags, func, arg, enc);
1937 # if FNM_SYSCASE || NORMALIZE_UTF8PATH 1941 if (!copy_beg)
return -1;
1942 for (cur = beg; cur < end; ++cur)
1943 *copy_end++ = (*cur)->
type <=
ALPHA ? *cur : 0;
1945 for (cur = copy_beg; cur < copy_end; ++cur) {
1956 memcpy(name, (*cur)->str, len);
1966 *new_end++ = (*cur)->
next;
1967 for (cur2 = cur + 1; cur2 < copy_end; ++cur2) {
1968 if (*cur2 &&
fnmatch((*cur2)->str, enc, name, flags) == 0) {
1969 *new_end++ = (*cur2)->
next;
1974 buf =
join_path(path, pathlen, dirsep, name, len);
1981 #if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME 1982 if ((*cur)->type ==
ALPHA) {
1983 long base = pathlen + (dirsep != 0);
1985 flags, &new_pathtype);
1989 new_pathtype, new_beg, new_end,
1990 flags, func, arg, enc);
2007 const char *root, *start;
2012 start = root =
path;
2018 if (*root ==
'/') root++;
2022 if (!buf)
return -1;
2023 MEMCPY(buf, start,
char, n);
2032 flags, func, arg, enc);
2075 #if defined _WIN32 || defined __APPLE__ 2091 const char *p = str;
2092 const char *pend = p +
strlen(p);
2094 const char *lbrace = 0, *rbrace = 0;
2095 int nest = 0, status = 0;
2098 if (*p ==
'{' && nest++ == 0) {
2101 if (*p ==
'}' && lbrace && --nest == 0) {
2105 if (*p ==
'\\' && escape) {
2111 if (lbrace && rbrace) {
2116 if (!buf)
return -1;
2117 memcpy(buf, s, lbrace-s);
2120 while (p < rbrace) {
2121 const char *t = ++p;
2123 while (p < rbrace && !(*p ==
',' && nest == 0)) {
2124 if (*p ==
'{') nest++;
2125 if (*p ==
'}') nest--;
2126 if (*p ==
'\\' && escape) {
2127 if (++p == rbrace)
break;
2131 memcpy(buf+shift, t, p-t);
2132 strlcpy(buf+shift+(p-t), rbrace+1, len-(shift+(p-t)));
2138 else if (!lbrace && !rbrace) {
2196 #if defined _WIN32 || defined __APPLE__ 2208 #if defined _WIN32 || defined __APPLE__ 2236 while (p < pend && !*p)
2250 for (i = 0; i <
argc; ++i) {
2252 VALUE str = argv[i];
2356 VALUE str, rflags, ary;
2359 if (
rb_scan_args(argc, argv,
"11", &str, &rflags) == 2)
2456 if (enc_pattern != enc_path) {
2465 enc_pattern, &cr) != len)
2574 if (
rb_scan_args(argc, argv,
"21", &pattern, &path, &rflags) == 3)
2617 user = (argc > 0) ? argv[0] :
Qnil;
2654 rb_warning(
"Dir.exists? is a deprecated name, use Dir.exist? instead");
2672 enum {false_on_notdir = 1};
2680 #if defined HAVE_GETATTRLIST && defined ATTR_DIR_ENTRYCOUNT 2682 u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)];
2683 struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,};
2684 if (getattrlist(path, &al, attrbuf,
sizeof(attrbuf), 0) != 0)
2686 if (*(
const fsobj_tag_t *)(attrbuf+1) == VT_HFS) {
2688 al.dirattr = ATTR_DIR_ENTRYCOUNT;
2689 if (getattrlist(path, &al, attrbuf,
sizeof(attrbuf), 0) == 0) {
2690 if (attrbuf[0] >= 2 *
sizeof(u_int32_t))
2692 if (false_on_notdir)
return Qfalse;
2709 if (false_on_notdir && e == ENOTDIR)
return Qfalse;
#define ENCINDEX_US_ASCII
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc)
static void dir_closed(void)
static char * join_path(const char *path, long len, int dirsep, const char *name, size_t namlen)
#define MBCLEN_CHARFOUND_P(ret)
static void dir_free(void *ptr)
static int chdir_blocking
void rb_bug(const char *fmt,...)
static VALUE dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
static int ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
#define RUBY_TYPED_FREE_IMMEDIATELY
long rb_str_coderange_scan_restartable(const char *, const char *, rb_encoding *, int *)
static VALUE chdir_restore(struct chdir_data *args)
size_t strlen(const char *)
static const rb_data_type_t dir_data_type
static VALUE chdir_thread
#define GLOB_REALLOC(ptr, size)
struct glob_pattern * next
void rb_syserr_fail(int e, const char *mesg)
unsigned int UINT8 __attribute__((__mode__(__QI__)))
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
enum glob_pattern_type type
void rb_file_const(const char *name, VALUE value)
int ruby_brace_glob_with_enc(const char *str, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
static VALUE dir_rewind(VALUE dir)
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
static VALUE file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
static struct dir_data * dir_get(VALUE dir)
int lstat(const char *path, struct stat *result)
void(* func)(const char *, VALUE, void *)
static VALUE dir_inspect(VALUE dir)
static DIR * do_opendir(const char *path, int flags, rb_encoding *enc)
#define TypedData_Get_Struct(obj, type, data_type, sval)
static void dir_chdir(VALUE path)
static VALUE dir_s_alloc(VALUE klass)
rb_encoding * rb_to_encoding(VALUE enc)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
VALUE rb_ary_each(VALUE ary)
static int glob_brace(const char *path, VALUE val, void *enc)
static size_t dir_memsize(const void *ptr)
void rb_must_asciicompat(VALUE)
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
SSL_METHOD *(* func)(void)
static VALUE glob_func_caller(VALUE val)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
#define FilePathStringValue(v)
static char * bracket(const char *p, const char *pend, const char *s, const char *send, int flags, rb_encoding *enc)
int ruby_glob(const char *path, int flags, ruby_glob_func *func, VALUE arg)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
int rb_gc_for_fd(int err)
static VALUE dir_s_chdir(int argc, VALUE *argv, VALUE obj)
void rb_raise(VALUE exc, const char *fmt,...)
#define RSTRING_GETMEM(str, ptrvar, lenvar)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
void rb_include_module(VALUE klass, VALUE module)
void rb_gc_mark(VALUE ptr)
static VALUE dir_globs(long argc, const VALUE *argv, int flags)
VALUE rb_utf8_str_new_cstr(const char *)
rb_encoding * rb_utf8_encoding(void)
VALUE rb_str_dup_frozen(VALUE)
int rb_w32_map_errno(DWORD)
static VALUE check_dirname(VALUE dir)
static int ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc)
#define ENC_CODERANGE_7BIT
RUBY_EXTERN void * memmove(void *, const void *, size_t)
int rb_enc_toupper(int c, rb_encoding *enc)
void rewinddir(DIR *dirp)
static VALUE dir_s_aref(int argc, VALUE *argv, VALUE obj)
char * rb_enc_path_skip_prefix(const char *path, const char *end, rb_encoding *enc)
static struct glob_pattern * glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc)
static int dirent_match(const char *pat, rb_encoding *enc, const char *name, const struct dirent *dp, int flags)
int rb_enc_to_index(rb_encoding *enc)
VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc)
VALUE rb_class_name(VALUE)
static int do_stat(const char *path, struct stat *pst, int flags, rb_encoding *enc)
int rb_block_given_p(void)
VALUE rb_str_encode_ospath(VALUE path)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_home_dir_of(VALUE user, VALUE result)
#define sys_warning(val, enc)
#define GetDIR(obj, dirp)
static VALUE rb_dir_s_empty_p(VALUE obj, VALUE dirname)
VALUE rb_str_cat2(VALUE, const char *)
static VALUE dir_s_home(int argc, VALUE *argv, VALUE obj)
VALUE rb_thread_current(void)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
#define GLOB_JUMP_TAG(status)
#define MEMCPY(p1, p2, type, n)
VALUE rb_enc_associate_index(VALUE obj, int idx)
#define rb_enc_codepoint(p, e, enc)
void seekdir(DIR *dirp, long offset)
static VALUE chdir_yield(struct chdir_data *args)
#define IF_NORMALIZE_UTF8PATH(something)
VALUE rb_str_resize(VALUE, long)
static enum glob_pattern_type has_magic(const char *p, const char *pend, int flags, rb_encoding *enc)
VALUE rb_str_subseq(VALUE, long, long)
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)
#define RARRAY_CONST_PTR(a)
static int to_be_ignored(int e)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
static VALUE dir_read(VALUE dir)
static int rb_glob_caller(const char *path, VALUE a, void *enc)
static int fnmatch_helper(const char **pcur, const char **scur, int flags, rb_encoding *enc)
ALWAYS_INLINE(static int to_be_ignored(int e))
static VALUE sys_warning_1(VALUE mesg)
int ruby_glob_func(const char *, VALUE, void *)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static void dir_mark(void *ptr)
static VALUE dir_s_rmdir(VALUE obj, VALUE dir)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_file_directory_p(VALUE obj, VALUE fname)
#define glob_call_func(func, path, arg, enc)
#define READDIR(dir, enc)
static VALUE dir_each(VALUE dir)
char * strchr(char *, char)
static VALUE dir_path(VALUE dir)
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
static VALUE rb_dir_exists_p(VALUE obj, VALUE fname)
#define rb_enc_asciicompat(enc)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
VALUE rb_str_new_cstr(const char *)
int memcmp(const void *s1, const void *s2, size_t len)
static struct dir_data * dir_check(VALUE dir)
#define rb_tainted_str_new2
static void shift(struct cparse_params *v, long act, VALUE tok, VALUE val)
void rb_sys_fail(const char *mesg)
void rb_glob(const char *path, void(*func)(const char *, VALUE, void *), VALUE arg)
static VALUE dir_s_glob(int argc, VALUE *argv, VALUE obj)
static VALUE dir_s_getwd(VALUE dir)
void rb_sys_enc_warning(rb_encoding *enc, const char *fmt,...)
register unsigned int len
#define StringValueCStr(v)
static char * remove_backslashes(char *p, register const char *pend, rb_encoding *enc)
rb_encoding * rb_enc_get(VALUE obj)
static int push_caller(const char *path, VALUE val, void *enc)
void * rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type)
static VALUE dir_close(VALUE)
static VALUE dir_entries(int argc, VALUE *argv, VALUE io)
static void glob_free_pattern(struct glob_pattern *list)
VALUE rb_check_array_type(VALUE ary)
static VALUE dir_initialize(int argc, VALUE *argv, VALUE dir)
int rb_w32_reparse_symlink_p(const WCHAR *path)
VALUE rb_default_home_dir(VALUE result)
struct rb_encoding_entry * list
rb_encoding * rb_filesystem_encoding(void)
static int to_be_skipped(const struct dirent *dp)
static int push_glob(VALUE ary, VALUE str, int flags)
#define TypedData_Make_Struct(klass, type, data_type, sval)
int ruby_brace_glob(const char *str, int flags, ruby_glob_func *func, VALUE arg)
static void push_pattern(const char *path, VALUE ary, void *enc)
static int fnmatch(const char *pattern, rb_encoding *enc, const char *string, int flags)
WCHAR * rb_w32_mbstr_to_wstr(UINT, const char *, int, long *)
#define RETURN_ENUMERATOR(obj, argc, argv)
#define SafeStringValue(v)
static VALUE dir_open_dir(int argc, VALUE *argv)
char * rb_enc_path_end(const char *path, const char *end, rb_encoding *enc)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
#define rb_sys_fail_path(path)
static VALUE dir_s_open(int argc, VALUE *argv, VALUE klass)
RUBY_EXTERN VALUE rb_eIOError
static char * find_dirsep(const char *p, const char *pend, int flags, rb_encoding *enc)
static VALUE dir_foreach(int argc, VALUE *argv, VALUE io)
VALUE rb_int2inum(SIGNED_VALUE n)
rb_encoding * rb_ascii8bit_encoding(void)
#define sys_enc_warning_in(func, mesg, enc)
void rb_warning(const char *fmt,...)
static VALUE rb_push_glob(VALUE str, int flags)
#define rb_syserr_fail_path(err, path)
#define rb_check_frozen(obj)
static int fnmatch_brace(const char *pattern, VALUE val, void *enc)
int rb_enc_str_asciionly_p(VALUE)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
void rb_warn(const char *fmt,...)
#define GLOB_ALLOC_N(type, n)
VALUE rb_enc_str_new_cstr(const char *, rb_encoding *)
#define GlobPathValue(str, safe)
VALUE rb_str_new(const char *, long)