[前][次][番号順一覧][スレッド一覧]

ruby-changes:28994

From: nobu <ko1@a...>
Date: Mon, 3 Jun 2013 19:02:51 +0900 (JST)
Subject: [ruby-changes:28994] nobu:r41046 (trunk): dir.c: use fd to fstatfs

nobu	2013-06-03 19:02:39 +0900 (Mon, 03 Jun 2013)

  New Revision: 41046

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41046

  Log:
    dir.c: use fd to fstatfs
    
    * dir.c (is_hfs): use the file descriptor instead of a path.

  Modified files:
    trunk/ChangeLog
    trunk/dir.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41045)
+++ ChangeLog	(revision 41046)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun  3 19:02:20 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (is_hfs): use the file descriptor instead of a path.
+
 Mon Jun  3 07:15:17 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* configure.in: removes AC_CHECK_FUNCS(readdir_r). readdir_r()
Index: dir.c
===================================================================
--- dir.c	(revision 41045)
+++ dir.c	(revision 41046)
@@ -97,10 +97,10 @@ rb_utf8mac_encoding(void) https://github.com/ruby/ruby/blob/trunk/dir.c#L97
 }
 
 static inline int
-is_hfs(const char *path)
+is_hfs(DIR *dirp)
 {
     struct statfs buf;
-    if (statfs(path, &buf) == 0) {
+    if (fstatfs(dirfd(dirp), &buf) == 0) {
 	return buf.f_type == 17; /* HFS on darwin */
     }
     return FALSE;
@@ -626,7 +626,7 @@ dir_each(VALUE dir) https://github.com/ruby/ruby/blob/trunk/dir.c#L626
     RETURN_ENUMERATOR(dir, 0, 0);
     GetDIR(dir, dirp);
     rewinddir(dirp->dir);
-    IF_HAVE_HFS(hfs_p = !NIL_P(dirp->path) && is_hfs(RSTRING_PTR(dirp->path)));
+    IF_HAVE_HFS(hfs_p = is_hfs(dirp->dir));
     while ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {
 	const char *name = dp->d_name;
 	size_t namlen = NAMLEN(dp);
@@ -1401,7 +1401,7 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L1401
 	IF_HAVE_HFS(int hfs_p);
 	dirp = do_opendir(*path ? path : ".", flags, enc);
 	if (dirp == NULL) return 0;
-	IF_HAVE_HFS(hfs_p = is_hfs(*path ? path : "."));
+	IF_HAVE_HFS(hfs_p = is_hfs(dirp));
 
 	while ((dp = READDIR(dirp, enc)) != NULL) {
 	    char *buf;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]