1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* win32/win32.c (rb_w32_opendir): use FindFirstFile()/FindNextFile()/

FindClose() instead of _findfirst()/_findnext()/_findclose().
  merge from HEAD.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2004-06-21 01:29:49 +00:00
parent 6c55c4eefd
commit dda47e42a8
2 changed files with 18 additions and 11 deletions

View file

@ -1,3 +1,9 @@
Mon Jun 21 10:19:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_opendir): use FindFirstFile()/FindNextFile()/
FindClose() instead of _findfirst()/_findnext()/_findclose().
merge from HEAD.
Sat Jun 19 13:24:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (method_call): allow changing $SAFE. [ruby-dev:23713]

View file

@ -1332,8 +1332,8 @@ rb_w32_opendir(const char *filename)
char scannamespc[PATHLEN];
char *scanname = scannamespc;
struct stat sbuf;
struct _finddata_t fd;
long fh;
WIN32_FIND_DATA fd;
HANDLE fh;
//
// check to see if we've got a directory
@ -1371,8 +1371,9 @@ rb_w32_opendir(const char *filename)
// do the FindFirstFile call
//
fh = _findfirst(scanname, &fd);
if (fh == -1) {
fh = FindFirstFile(scanname, &fd);
if (fh == INVALID_HANDLE_VALUE) {
errno = map_errno(GetLastError());
return NULL;
}
@ -1381,19 +1382,19 @@ rb_w32_opendir(const char *filename)
// filenames that we find.
//
idx = strlen(fd.name)+1;
idx = strlen(fd.cFileName)+1;
p->start = ALLOC_N(char, idx);
strcpy(p->start, fd.name);
strcpy(p->start, fd.cFileName);
p->nfiles++;
//
// loop finding all the files that match the wildcard
// (which should be all of them in this directory!).
// the variable idx should point one past the null terminator
// of the previous string found.
//
while (_findnext(fh, &fd) == 0) {
len = strlen(fd.name);
while (FindNextFile(fh, &fd)) {
len = strlen(fd.cFileName);
//
// bump the string table size by enough for the
@ -1406,11 +1407,11 @@ rb_w32_opendir(const char *filename)
if (p->start == NULL) {
rb_fatal ("opendir: malloc failed!\n");
}
strcpy(&p->start[idx], fd.name);
strcpy(&p->start[idx], fd.cFileName);
p->nfiles++;
idx += len+1;
}
_findclose(fh);
FindClose(fh);
p->size = idx;
p->curr = p->start;
return p;