diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-02 16:21:26 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-02 16:21:26 +0000 |
commit | 59dbfa3e4cc8d4705ef5a4abd9904fa523f26bfa (patch) | |
tree | dceea3234a395183be7e17858fbbf80ef291e984 /win32/win32.c | |
parent | 88c127c19be3d12bc5edcb6ceb416985258396c6 (diff) | |
download | ruby-59dbfa3e4cc8d4705ef5a4abd9904fa523f26bfa.tar.gz |
* dir.c: merge tuning from H.Yamamoto <ocean@m2.ccsnet.ne.jp>.
[ruby-dev:22476]
* io.c (argf_eof): ARGF.eof? should not have any side effect.
[ruby-dev:22469]
* io.c (argf_each_byte): should return self. [ruby-dev:22465]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c index 966c326466..5ea7eccb1a 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1384,6 +1384,8 @@ rb_w32_opendir(const char *filename) idx = strlen(fd.name)+1; p->start = ALLOC_N(char, idx); strcpy(p->start, fd.name); + p->bits = ALLOC_N(char, 1); + p->bits[0] = fd.attrib & _A_SUBDIR ? 1 : 0; p->nfiles++; // @@ -1407,6 +1409,18 @@ rb_w32_opendir(const char *filename) rb_fatal ("opendir: malloc failed!\n"); } strcpy(&p->start[idx], fd.name); + + if (p->nfiles % 8 == 0) { + Renew (p->bits, p->nfiles / 8 + 1, char); + if (p->bits == NULL) { + rb_fatal ("opendir: malloc failed!\n"); + } + p->bits[p->nfiles / 8] = 0; + } + if (fd.attrib & _A_SUBDIR) { + p->bits[p->nfiles / 8] |= (1 << p->nfiles % 8); + } + p->nfiles++; idx += len+1; } @@ -1444,6 +1458,12 @@ rb_w32_readdir(DIR *dirp) dirp->dirstr.d_ino = dummy++; // + // Directory flag + // + dirp->dirstr.d_isdir = dirp->bits[dirp->bitpos / 8] & (1 << dirp->bitpos % 8); + dirp->bitpos++; + + // // Now set up for the next call to readdir // @@ -1486,6 +1506,7 @@ void rb_w32_rewinddir(DIR *dirp) { dirp->curr = dirp->start; + dirp->bitpos = 0; } // @@ -1496,6 +1517,7 @@ void rb_w32_closedir(DIR *dirp) { free(dirp->start); + free(dirp->bits); free(dirp); } |