[PATCH] avoid MAXPATHLEN dependency

Samuel Thibault samuel.thibault@ens-lyon.org
Tue Jul 24 20:52:00 GMT 2007


Hi,

Some systems don't have such hard limit as MAXPATHLEN, here is a patch
to take advantage of this.

Samuel
-------------- next part --------------
libjava/ChangeLog
2005-10-01  Alfred M. Szmidt  <ams@gnu.org>

	* java/io/natFilePosix.cc (init_native) [!MAXPATHLEN]: Define to 0.
	* java/io/File.java (createTempFile): Don't truncate if the system
	doesn't have a limit on the length of a file name.

Index: libjava/java/io/File.java
===================================================================
--- libjava/java/io/File.java	(r??vision 126889)
+++ libjava/java/io/File.java	(copie de travail)
@@ -117,6 +117,7 @@
   public static final char pathSeparatorChar = pathSeparator.charAt(0);
 
   static final String tmpdir = System.getProperty("java.io.tmpdir");
+  /* If 0, then the system doesn't have a file name length limit.  */
   static int maxPathLen;
   static boolean caseSensitive;
   
@@ -1130,7 +1131,9 @@
 
     // Truncation rules.
     // `6' is the number of characters we generate.
-    if (prefix.length() + 6 + suffix.length() > maxPathLen)
+    // If maxPathLen equals zero, then the system doesn't have a limit
+    // on the file name, so there is nothing to truncate.
+    if (maxPathLen > 0 && prefix.length() + 6 + suffix.length() > maxPathLen)
       {
 	int suf_len = 0;
 	if (suffix.charAt(0) == '.')
Index: libjava/java/io/natFilePosix.cc
===================================================================
--- libjava/java/io/natFilePosix.cc	(r??vision 126889)
+++ libjava/java/io/natFilePosix.cc	(copie de travail)
@@ -504,6 +504,12 @@
 void
 java::io::File::init_native ()
 {
+#ifdef MAXPATHLEN
   maxPathLen = MAXPATHLEN;
+#else
+  /* Some systems do not have a limit on the length of a file name,
+     the GNU system is one such example.  */
+  maxPathLen = 0;
+#endif
   caseSensitive = true;
 }


More information about the Java-patches mailing list