summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-03 10:02:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-03 10:02:39 +0000
commit482f0e6b97330a1321bccdc5c80b988b5068a5b8 (patch)
tree7852227fc8d3c9c098487f5f8444e67fc2ef04af
parentc120db4547592a0b96b14d1fcd372968442032b2 (diff)
dir.c: use fd to fstatfs
* dir.c (is_hfs): use the file descriptor instead of a path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--dir.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ff140acb6..c00ba076ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Jun 3 19:02:20 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dir.c (is_hfs): use the file descriptor instead of a path.
+
Mon Jun 3 07:15:17 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* configure.in: removes AC_CHECK_FUNCS(readdir_r). readdir_r()
diff --git a/dir.c b/dir.c
index 23b5437cbe..4b010351f2 100644
--- a/dir.c
+++ b/dir.c
@@ -97,10 +97,10 @@ rb_utf8mac_encoding(void)
}
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)
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(
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;