harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r786106 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c
Date Thu, 18 Jun 2009 15:08:28 GMT
Author: tellison
Date: Thu Jun 18 15:08:28 2009
New Revision: 786106

URL: http://svn.apache.org/viewvc?rev=786106&view=rev
Log:
Improve error message for path too long exception.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c?rev=786106&r1=786105&r2=786106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c Thu Jun
18 15:08:28 2009
@@ -23,6 +23,14 @@
 #include "helpers.h"
 #include "jclprots.h"
 
+void
+throwPathTooLongIOException(JNIEnv *env, jsize length)
+{
+  char errorString[100];
+  sprintf(errorString, "Path length of %d characters exceeds maximum supported length of
%d", length, HyMaxPath-1);
+  throwJavaIoIOException(env, errorString);
+}
+
 JNIEXPORT jboolean JNICALL
 Java_java_io_File_deleteFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
 {
@@ -31,7 +39,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -48,7 +56,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -80,7 +88,7 @@
   currentEntry = NULL;
 
   if (length >= HyMaxPath) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -161,7 +169,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -178,7 +186,7 @@
   char pathCopy[HyMaxPath];
   jsize length = (*env)->GetArrayLength (env, path);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -195,7 +203,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -213,7 +221,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -231,7 +239,7 @@
   char pathCopy[HyMaxPath];
 
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -282,7 +290,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path length exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -299,16 +307,19 @@
   I_32 result;
   jsize length;
   char pathExistCopy[HyMaxPath], pathNewCopy[HyMaxPath];
+  char errorString[100];
   length = (*env)->GetArrayLength (env, pathExist);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "old path exceeds maximum supported length");
+    sprintf(errorString, "Old path length of %d characters exceeds maximum supported length
of %d", length, HyMaxPath-1);
+    throwJavaIoIOException(env, errorString);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, pathExist, 0, length, (jbyte *)pathExistCopy));
   pathExistCopy[length] = '\0';
   length = (*env)->GetArrayLength (env, pathNew);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "new path exceeds maximum supported length");
+    sprintf(errorString, "New path length of %d characters exceeds maximum supported length
of %d", length, HyMaxPath-1);
+    throwJavaIoIOException(env, errorString);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, pathNew, 0, length, (jbyte *)pathNewCopy));
@@ -328,7 +339,7 @@
   char pathCopy[HyMaxPath];
   U_32 length = (U_32) (*env)->GetArrayLength (env, path);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   (*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy);
@@ -351,7 +362,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -421,7 +432,7 @@
   char pathCopy[HyMaxPath];
   jsize length = (*env)->GetArrayLength (env, path);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -438,7 +449,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -456,7 +467,7 @@
   jsize length = (*env)->GetArrayLength (env, path);
   char pathCopy[HyMaxPath];
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -490,7 +501,7 @@
   char pathCopy[HyMaxPath];
   jsize length = (*env)->GetArrayLength (env, path);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -507,7 +518,7 @@
   char pathCopy[HyMaxPath];
   jsize length = (*env)->GetArrayLength (env, path);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   ((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -524,7 +535,7 @@
   char pathCopy[HyMaxPath];
   U_32 length = (U_32) (*env)->GetArrayLength (env, path);
   if (length > HyMaxPath-1) {
-    throwJavaIoIOException(env, "path exceeds maximum supported length");
+    throwPathTooLongIOException(env, length);
     return 0;
   }
   (*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy);



Mime
View raw message