mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
c120db4547
commit
482f0e6b97
2 changed files with 8 additions and 4 deletions
|
@ -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()
|
||||
|
|
8
dir.c
8
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;
|
||||
|
|
Loading…
Reference in a new issue