Also update two comments in the moved structure to refer to _wfindnext
instead of _findnext.
DIR and _WDIR are supposed to be opaque structures which applications
shouldn't access directly. Also, their arrangement was incorrect from
applications' point of view if _USE_32BIT_TIME_T was defined due to
how _wfinddata_t is defined.
---
mingw-w64-crt/misc/dirent.c | 58 ++++++++++++++++++++++++++++++
mingw-w64-headers/crt/dirent.h | 65 ++--------------------------------
2 files changed, 60 insertions(+), 63 deletions(-)
diff --git a/mingw-w64-crt/misc/dirent.c b/mingw-w64-crt/misc/dirent.c
index f58e44b7f..5d3f921a8 100644
--- a/mingw-w64-crt/misc/dirent.c
+++ b/mingw-w64-crt/misc/dirent.c
@@ -30,6 +30,64 @@
#include <tchar.h>
+struct __dirent_DIR
+{
+ /* disk transfer area for this dir */
+ struct _wfinddata_t dd_dta;
+
+ /* dirent struct to return from dir (NOTE: this makes this thread
+ * safe as long as only one thread uses a particular DIR struct at
+ * a time) */
+ struct dirent dd_dir;
+
+ /* _wfindnext handle */
+ intptr_t dd_handle;
+
+ /*
+ * Status of search:
+ * 0 = not started yet (next entry to read is first entry)
+ * -1 = off the end
+ * positive = 0 based index of next entry
+ */
+ int dd_stat;
+
+ /* If readdir skips any filenames, this is set to a non-zero error
+ * number. If dd_errno is non-zero at the end of the directory,
+ * readdir sets errno = dd_errno, dd_errno = 0, and returns NULL.
+ * So if readdir is called again, it won't modify errno again. */
+ unsigned int dd_errno;
+
+ /* given path for dir with search pattern (struct is extended) */
+ wchar_t dd_name[1];
+};
+
+
+struct __wdirent_WDIR
+{
+ /* disk transfer area for this dir */
+ struct _wfinddata_t dd_dta;
+
+ /* dirent struct to return from dir (NOTE: this makes this thread
+ * safe as long as only one thread uses a particular DIR struct at
+ * a time) */
+ struct _wdirent dd_dir;
+
+ /* _wfindnext handle */
+ intptr_t dd_handle;
+
+ /*
+ * Status of search:
+ * 0 = not started yet (next entry to read is first entry)
+ * -1 = off the end
+ * positive = 0 based index of next entry
+ */
+ int dd_stat;
+
+ /* given path for dir with search pattern (struct is extended) */
+ wchar_t dd_name[1];
+};
+
+
/*
* opendir
*
diff --git a/mingw-w64-headers/crt/dirent.h b/mingw-w64-headers/crt/dirent.h
index f0e1f52b4..95050e61c 100644
--- a/mingw-w64-headers/crt/dirent.h
+++ b/mingw-w64-headers/crt/dirent.h
@@ -30,41 +30,7 @@ struct dirent
char d_name[255 * 3 + 1]; /* [NAME_MAX] */ /* File name. */
};
-/*
- * This is an internal data structure. Good programmers will not use it
- * except as an argument to one of the functions below.
- * dd_stat field is now int (was short in older versions).
- */
-typedef struct
-{
- /* disk transfer area for this dir */
- struct _wfinddata_t dd_dta;
-
- /* dirent struct to return from dir (NOTE: this makes this thread
- * safe as long as only one thread uses a particular DIR struct at
- * a time) */
- struct dirent dd_dir;
-
- /* _findnext handle */
- intptr_t dd_handle;
-
- /*
- * Status of search:
- * 0 = not started yet (next entry to read is first entry)
- * -1 = off the end
- * positive = 0 based index of next entry
- */
- int dd_stat;
-
- /* If readdir skips any filenames, this is set to a non-zero error
- * number. If dd_errno is non-zero at the end of the directory,
- * readdir sets errno = dd_errno, dd_errno = 0, and returns NULL.
- * So if readdir is called again, it won't modify errno again. */
- unsigned int dd_errno;
-
- /* given path for dir with search pattern (struct is extended) */
- wchar_t dd_name[1];
-} DIR;
+typedef struct __dirent_DIR DIR;
DIR* __cdecl __MINGW_NOTHROW opendir (const char*);
struct dirent* __cdecl __MINGW_NOTHROW readdir (DIR*);
@@ -84,34 +50,7 @@ struct _wdirent
wchar_t d_name[260]; /* [FILENAME_MAX] */ /* File name. */
};
-/*
- * This is an internal data structure. Good programmers will not use it
- * except as an argument to one of the functions below.
- */
-typedef struct
-{
- /* disk transfer area for this dir */
- struct _wfinddata_t dd_dta;
-
- /* dirent struct to return from dir (NOTE: this makes this thread
- * safe as long as only one thread uses a particular DIR struct at
- * a time) */
- struct _wdirent dd_dir;
-
- /* _findnext handle */
- intptr_t dd_handle;
-
- /*
- * Status of search:
- * 0 = not started yet (next entry to read is first entry)
- * -1 = off the end
- * positive = 0 based index of next entry
- */
- int dd_stat;
-
- /* given path for dir with search pattern (struct is extended) */
- wchar_t dd_name[1];
-} _WDIR;
+typedef struct __wdirent_WDIR _WDIR;
_WDIR* __cdecl __MINGW_NOTHROW _wopendir (const wchar_t*);
struct _wdirent* __cdecl __MINGW_NOTHROW _wreaddir (_WDIR*);
--
2.47.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public