diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-25 03:31:19 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-25 03:31:19 +0000 |
commit | ce8859c5563493a94f57d3b630e7b9c1d3cd656f (patch) | |
tree | eefe3446c88ef90ff4d3578ae925b4e69d762822 /dir.c | |
parent | 75ff8fdb16fa0a733512e61350c9844ea530ad35 (diff) |
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1dev@344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -119,7 +119,7 @@ dir_read(dir) errno = 0; dp = readdir(dirp); if (dp) - return rb_str_taint(rb_str_new(dp->d_name, NAMLEN(dp))); + return rb_tainted_str_new(dp->d_name, NAMLEN(dp)); else if (errno == 0) { /* end of stream */ return Qnil; } @@ -138,7 +138,7 @@ dir_each(dir) GetDIR(dir, dirp); for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { - file = rb_str_taint(rb_str_new(dp->d_name, NAMLEN(dp))); + file = rb_tainted_str_new(dp->d_name, NAMLEN(dp)); rb_yield(file); } return dir; @@ -240,7 +240,7 @@ dir_s_getwd(dir) if (getwd(path) == 0) rb_sys_fail(path); #endif - return rb_str_taint(rb_str_new2(path)); + return rb_tainted_str_new2(path); } static VALUE @@ -317,7 +317,7 @@ push_globs(ary, s) if (fnames == (char**)-1) rb_sys_fail(s); ff = fnames; while (*ff) { - rb_ary_push(ary, rb_str_taint(rb_str_new2(*ff))); + rb_ary_push(ary, rb_tainted_str_new2(*ff)); free(*ff); ff++; } @@ -427,6 +427,16 @@ dir_foreach(io, dirname) return rb_ensure(dir_each, dir, dir_close, dir); } +static VALUE +dir_entries(io, dirname) + VALUE io, dirname; +{ + VALUE dir; + + dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname); + return rb_ensure(rb_Array, dir, dir_close, dir); +} + void Init_Dir() { @@ -437,6 +447,7 @@ Init_Dir() rb_define_singleton_method(rb_cDir, "new", dir_s_open, 1); rb_define_singleton_method(rb_cDir, "open", dir_s_open, 1); rb_define_singleton_method(rb_cDir, "foreach", dir_foreach, 1); + rb_define_singleton_method(rb_cDir, "entries", dir_entries, 1); rb_define_method(rb_cDir,"read", dir_read, 0); rb_define_method(rb_cDir,"each", dir_each, 0); |