commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r812823 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/io/Status.java native/shared/error.c
Date Wed, 09 Sep 2009 08:42:51 GMT
Author: mturk
Date: Wed Sep  9 08:42:51 2009
New Revision: 812823

URL: http://svn.apache.org/viewvc?rev=812823&view=rev
Log:
Add STATUS_IS methods

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java?rev=812823&r1=812822&r2=812823&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java
Wed Sep  9 08:42:51 2009
@@ -423,4 +423,19 @@
         return ((s > OS_START_STATUS) && (s < OS_START_STATUS + 1000));
     }
 
+    private static native boolean is0(int what, int err);
+
+    /** Permission denied */
+    public static boolean STATUS_IS_EACCES(int s)
+    {
+        return is0(EACCES, s);
+    }
+
+    /** File exists */
+    public static boolean STATUS_IS_EEXIST(int s)
+    {
+        return is0(EEXIST, s);
+    }
+
+    /* TODO: Implement the remaining of STATUS_IS methods */
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=812823&r1=812822&r2=812823&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Wed Sep  9 08:42:51 2009
@@ -799,3 +799,96 @@
     x_free(i);
 }
 
+ACR_JNI_EXPORT_DECLARE(jboolean, io_Status, is0)(ACR_JNISTDARGS,
+                                                 jint what, jint err)
+{
+    int is = 0;
+
+    UNREFERENCED_STDARGS;
+    switch (what) {
+        case ACR_EACCES:
+            is = ACR_STATUS_IS_EACCES(err);
+        break;
+        case ACR_EEXIST:
+            is = ACR_STATUS_IS_EEXIST(err);
+        break;
+        case ACR_ENAMETOOLONG:
+            is = ACR_STATUS_IS_ENAMETOOLONG(err);
+        break;
+        case ACR_ENOENT:
+            is = ACR_STATUS_IS_ENOENT(err);
+        break;
+        case ACR_ENOTDIR:
+            is = ACR_STATUS_IS_ENOTDIR(err);
+        break;
+        case ACR_ENOSPC:
+            is = ACR_STATUS_IS_ENOSPC(err);
+        break;
+        case ACR_ENOMEM:
+            is = ACR_STATUS_IS_ENOMEM(err);
+        break;
+        case ACR_EMFILE:
+            is = ACR_STATUS_IS_EMFILE(err);
+        break;
+        case ACR_ENFILE:
+            is = ACR_STATUS_IS_ENFILE(err);
+        break;
+        case ACR_EBADF:
+            is = ACR_STATUS_IS_EBADF(err);
+        break;
+        case ACR_EINVAL:
+            is = ACR_STATUS_IS_EINVAL(err);
+        break;
+        case ACR_ESPIPE:
+            is = ACR_STATUS_IS_ESPIPE(err);
+        break;
+        case ACR_EAGAIN:
+            is = ACR_STATUS_IS_EAGAIN(err);
+        break;
+        case ACR_EINTR:
+            is = ACR_STATUS_IS_EINTR(err);
+        break;
+        case ACR_ENOTSOCK:
+            is = ACR_STATUS_IS_ENOTSOCK(err);
+        break;
+        case ACR_ECONNREFUSED:
+            is = ACR_STATUS_IS_ECONNREFUSED(err);
+        break;
+        case ACR_EINPROGRESS:
+            is = ACR_STATUS_IS_EINPROGRESS(err);
+        break;
+        case ACR_ECONNABORTED:
+            is = ACR_STATUS_IS_ECONNABORTED(err);
+        break;
+        case ACR_ECONNRESET:
+            is = ACR_STATUS_IS_ECONNRESET(err);
+        break;
+        case ACR_TIMEUP:
+            is = ACR_STATUS_IS_TIMEUP(err);
+        break;
+        case ACR_EHOSTUNREACH:
+            is = ACR_STATUS_IS_EHOSTUNREACH(err);
+        break;
+        case ACR_ENETUNREACH:
+            is = ACR_STATUS_IS_ENETUNREACH(err);
+        break;
+        case ACR_EFTYPE:
+            is = ACR_STATUS_IS_EFTYPE(err);
+        break;
+        case ACR_EPIPE:
+            is = ACR_STATUS_IS_EPIPE(err);
+        break;
+        case ACR_EXDEV:
+            is = ACR_STATUS_IS_EXDEV(err);
+        break;
+        case ACR_ENOTEMPTY:
+            is = ACR_STATUS_IS_ENOTEMPTY(err);
+        break;
+        case ACR_EAFNOSUPPORT:
+            is = ACR_STATUS_IS_EAFNOSUPPORT(err);
+        break;
+        default:
+        break;
+    }
+    return is ? JNI_TRUE : JNI_FALSE;
+}



Mime
View raw message