summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-21 01:29:49 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-21 01:29:49 +0000
commitdda47e42a8f3db81dac74ee1f1c552f85b7f98ff (patch)
tree107fca3846c5e785af85a0b5b22b9e49a3136424 /win32/win32.c
parent6c55c4eefd3bdbc4ae29ab4c55fd7ffcf25b4fa6 (diff)
* 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
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 966c326466..ac97b201e9 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -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;