]> granicus.if.org Git - php/commitdiff
Fixed bug #11214 (patch by Steph Fox)
authorEdin Kadribasic <edink@php.net>
Mon, 29 Jul 2002 13:12:57 +0000 (13:12 +0000)
committerEdin Kadribasic <edink@php.net>
Mon, 29 Jul 2002 13:12:57 +0000 (13:12 +0000)
win32/readdir.c
win32/readdir.h

index 694a409c35f25afc0922cfe0c51e6498a2f7f33e..e33d19bde5be274629d90685518a4748c703e348 100644 (file)
@@ -113,29 +113,31 @@ int closedir(DIR *dp)
        return 0;
 }
 
-void rewinddir(DIR *dir_Info)
+int rewinddir(DIR *dp)
 {
        /* Re-set to the beginning */
        char *filespec;
        long handle;
        int index;
 
-       dir_Info->handle = 0;
-       dir_Info->offset = 0;
-       dir_Info->finished = 0;
+       _findclose(dp->handle);
 
-       filespec = malloc(strlen(dir_Info->dir) + 2 + 1);
-       strcpy(filespec, dir_Info->dir);
+       dp->offset = 0;
+       dp->finished = 0;
+
+       filespec = malloc(strlen(dp->dir) + 2 + 1);
+       strcpy(filespec, dp->dir);
        index = strlen(filespec) - 1;
        if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
                filespec[index] = '\0';
        strcat(filespec, "/*");
 
-       if ((handle = _findfirst(filespec, &(dir_Info->fileinfo))) < 0) {
-               if (errno == ENOENT) {
-                       dir_Info->finished = 1;
+       if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
+               if (errno == ENOENT)
+                       dp->finished = 1;
                }
-       }
-       dir_Info->handle = handle;
+       dp->handle = handle;
        free(filespec);
+
+return 0;
 }
index b0f1ad9e6f99b386a8ee656f8095be9bc681e044..aed9a447889c210650c5ebf6aae56f7d7d583fa5 100644 (file)
@@ -38,7 +38,7 @@ DIR *opendir(const char *);
 struct dirent *readdir(DIR *);
 int readdir_r(DIR *, struct dirent *, struct dirent **);
 int closedir(DIR *);
-void rewinddir(DIR *);
+int rewinddir(DIR *);
 
 
 #endif /* READDIR_H */