NAME_MAX is a POSIX constant; Windows doesn't define it. For this
reason, assume that NAME_MAX is only about filenames in multibyte
representation. In the UTF-8 code page, filenames can be up to
255 * 3 bytes excluding the terminating null character. (It's not
255 * 4 because four-byte UTF-8 characters consume two UTF-16
code units.)
If I have understood correctly, there is no Windows locale that
supports a code page with longer encodings. For example, a single
UTF-16 code unit may produce four bytes in GB18030 but it cannot
be used as a locale code page.
Update "struct dirent" in <dirent.h> to use the new value for d_name[].
"struct _wdirent" isn't modified because for wide char filenames the
current value is good.
---
mingw-w64-headers/crt/dirent.h | 2 +-
mingw-w64-headers/crt/limits.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-headers/crt/dirent.h b/mingw-w64-headers/crt/dirent.h
index 272662d65..f0e1f52b4 100644
--- a/mingw-w64-headers/crt/dirent.h
+++ b/mingw-w64-headers/crt/dirent.h
@@ -27,7 +27,7 @@ struct dirent
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
- char d_name[260]; /* [FILENAME_MAX] */ /* File name. */
+ char d_name[255 * 3 + 1]; /* [NAME_MAX] */ /* File name. */
};
/*
diff --git a/mingw-w64-headers/crt/limits.h b/mingw-w64-headers/crt/limits.h
index f0145dfb1..60172eafb 100644
--- a/mingw-w64-headers/crt/limits.h
+++ b/mingw-w64-headers/crt/limits.h
@@ -105,7 +105,7 @@
#define LINK_MAX 1024
#define MAX_CANON _POSIX_MAX_CANON
#define MAX_INPUT _POSIX_MAX_INPUT
-#define NAME_MAX 255
+#define NAME_MAX 765
#define NGROUPS_MAX 16
#define OPEN_MAX 32
#undef PATH_MAX
--
2.47.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public