pathmax: Support for native Windows.
authorBruno Haible <bruno@clisp.org>
Tue, 13 Sep 2011 11:02:16 +0000 (13:02 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 13 Sep 2011 11:02:16 +0000 (13:02 +0200)
* lib/pathmax.h (PATH_MAX): Define to 260 on native Windows.

ChangeLog
lib/pathmax.h

index 3c17730..c6bfc74 100644 (file)
--- 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'.
index a1e458c..9c30995 100644 (file)
 #  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 */