changeset 15611:ddf0241e1a64

pathmax: Support for native Windows. * lib/pathmax.h (PATH_MAX): Define to 260 on native Windows.
author Bruno Haible <bruno@clisp.org>
date Tue, 13 Sep 2011 13:02:16 +0200
parents de2ecfd7fc4a
children 7bff02eb5553
files ChangeLog lib/pathmax.h
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-13  Bruno Haible  <bruno@clisp.org>
+
+	pathmax: Support for native Windows.
+	* lib/pathmax.h (PATH_MAX): Define to 260 on native Windows.
+
 2011-09-12  Bruno Haible  <bruno@clisp.org>
 
 	New modules 'opendir', 'readdir', 'rewinddir', 'closedir'.
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -66,4 +66,19 @@
 #  define PATH_MAX 1024
 # endif
 
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
+   section "Maximum Path Length Limitation",
+   <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
+   explains that the maximum size of a filename, including the terminating
+   NUL byte, is 260 = 3 + 256 + 1.
+   This is the same value as
+     - FILENAME_MAX in <stdio.h>,
+     - _MAX_PATH in <stdlib.h>,
+     - MAX_PATH in <windef.h>.
+   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
+#  undef PATH_MAX
+#  define PATH_MAX 260
+# endif
+
 #endif /* _PATHMAX_H */