summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
commit7ea2ceddb832b9973694fecac9fe3c30400735ba (patch)
treea9b60dec20fa5f7f52ca7c8113195f2d65728a22 /dir.c
parent62e41d3f2e48422bbdf1bb2db83ae60b255b1a1a (diff)
This commit was generated by cvs2svn to compensate for changes in r11,
which included commits to RCS files with non-trunk default branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/dir.c b/dir.c
index d8f56f5d5f..29ce261272 100644
--- a/dir.c
+++ b/dir.c
@@ -13,15 +13,16 @@
#include "ruby.h"
#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include <sys/stat.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#else
# define MAXPATHLEN 1024
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#if HAVE_DIRENT_H
# include <dirent.h>
@@ -60,22 +61,21 @@ free_dir(dir)
static VALUE
dir_s_open(dir_class, dirname)
- VALUE dir_class;
- struct RString *dirname;
+ VALUE dir_class, dirname;
{
VALUE obj;
DIR *dirp;
Check_SafeStr(dirname);
- dirp = opendir(dirname->ptr);
+ dirp = opendir(RSTRING(dirname)->ptr);
if (dirp == NULL) {
if (errno == EMFILE || errno == ENFILE) {
- gc();
- dirp = opendir(dirname->ptr);
+ gc_gc();
+ dirp = opendir(RSTRING(dirname)->ptr);
}
if (dirp == NULL) {
- rb_sys_fail(dirname->ptr);
+ rb_sys_fail(RSTRING(dirname)->ptr);
}
}
@@ -178,7 +178,7 @@ dir_s_chdir(argc, argv, obj)
rb_secure(2);
rb_scan_args(argc, argv, "01", &path);
- if (path) {
+ if (!NIL_P(path)) {
Check_SafeStr(path);
dist = RSTRING(path)->ptr;
}
@@ -259,13 +259,12 @@ dir_s_mkdir(argc, argv, obj)
static VALUE
dir_s_rmdir(obj, dir)
- VALUE obj;
- struct RString *dir;
+ VALUE obj, dir;
{
rb_secure(2);
Check_SafeStr(dir);
- if (rmdir(dir->ptr) < 0)
- rb_sys_fail(dir->ptr);
+ if (rmdir(RSTRING(dir)->ptr) < 0)
+ rb_sys_fail(RSTRING(dir)->ptr);
return TRUE;
}
@@ -342,18 +341,18 @@ push_braces(ary, s)
}
static VALUE
-dir_s_glob(dir, str)
- VALUE dir;
- struct RString *str;
+dir_s_glob(dir, vstr)
+ VALUE dir, vstr;
{
char *p, *pend;
char buf[MAXPATHLEN];
char *t, *t0;
int nest;
VALUE ary;
+ struct RString *str;
- Check_SafeStr(str);
-
+ Check_SafeStr(vstr);
+ str = RSTRING(vstr);
ary = ary_new();
p = str->ptr;
@@ -386,8 +385,7 @@ dir_s_glob(dir, str)
static VALUE
dir_foreach(io, dirname)
- VALUE io;
- struct RString *dirname;
+ VALUE io, dirname;
{
VALUE dir;