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