aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
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 /dir.c
parentc120db4547592a0b96b14d1fcd372968442032b2 (diff)
downloadruby-482f0e6b97330a1321bccdc5c80b988b5068a5b8.tar.gz
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
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c8
1 files changed, 4 insertions, 4 deletions
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;