cvs: php4 / config.w32.h /win32/ readdir.c readdir.h

[email protected] ("Sascha Schumann")
Newsgroups php.version4
Message-ID <cvssas959093923@cvsserver>
sas		Tue May 23 16:58:43 2000 EDT

  Modified files:
    /php4	config.w32.h 
    /php4/win32	readdir.c readdir.h 
  Log:
  Add POSIX-like readdir_r for Win32
  
  
Index: php4/config.w32.h
diff -u php4/config.w32.h:1.25 php4/config.w32.h:1.26
--- php4/config.w32.h:1.25	Thu May 18 21:45:30 2000
+++ php4/config.w32.h	Tue May 23 16:58:43 2000
@@ -96,6 +96,7 @@
 
 
 #define HAVE_GETCWD 1
+#define HAVE_POSIX_READDIR_R 1
 
 #define NEED_ISBLANK 1
 /* ----------------------------------------------------------------
Index: php4/win32/readdir.c
diff -u php4/win32/readdir.c:1.2 php4/win32/readdir.c:1.3
--- php4/win32/readdir.c:1.2	Sat Sep 18 21:13:38 1999
+++ php4/win32/readdir.c	Tue May 23 16:58:43 2000
@@ -50,7 +50,7 @@
 	return dp;
 }
 
-struct dirent *readdir(DIR * dp)
+struct dirent *readdir(DIR *dp)
 {
 	if (!dp || dp->finished)
 		return NULL;
@@ -71,7 +71,39 @@
 	return &(dp->dent);
 }
 
-int closedir(DIR * dp)
+int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result)
+{
+	if (!dp || dp->finished) {
+		if (result) 
+			*result = NULL;
+		return 0;
+	}
+
+	if (dp->offset != 0) {
+		if (_findnext(dp->handle, &(dp->fileinfo)) < 0) {
+			dp->finished = 1;
+			if (result) 
+				*result = NULL;
+			return 0;
+		}
+	}
+	dp->offset++;
+
+	strlcpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME+1);
+	dp->dent.d_ino = 1;
+	dp->dent.d_reclen = strlen(dp->dent.d_name);
+	dp->dent.d_off = dp->offset;
+
+	if (entry)
+		memcpy(entry, &dp->dent, sizeof(*entry));
+
+	if (result)
+		*result = &dp->dent;
+
+	return 0;
+}
+
+int closedir(DIR *dp)
 {
 	if (!dp)
 		return 0;
Index: php4/win32/readdir.h
diff -u php4/win32/readdir.h:1.2 php4/win32/readdir.h:1.3
--- php4/win32/readdir.h:1.2	Sun Sep  5 21:04:40 1999
+++ php4/win32/readdir.h	Tue May 23 16:58:43 2000
@@ -32,6 +32,7 @@
 /* Function prototypes */
 DIR *opendir(const char *);
 struct dirent *readdir(DIR *);
+int readdir_r(DIR *, struct dirent *, struct dirent **);
 int closedir(DIR *);
 void rewinddir(DIR *);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.