commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1092786 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/io/FileDescriptorFactory.java java/org/apache/commons/runtime/io/Utils.java native/shared/iofd.c
Date Fri, 15 Apr 2011 18:53:39 GMT
Author: mturk
Date: Fri Apr 15 18:53:39 2011
New Revision: 1092786

URL: http://svn.apache.org/viewvc?rev=1092786&view=rev
Log:
Add initial IO Utils class

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java 
 (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileDescriptorFactory.java
    commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileDescriptorFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileDescriptorFactory.java?rev=1092786&r1=1092785&r2=1092786&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileDescriptorFactory.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileDescriptorFactory.java
Fri Apr 15 18:53:39 2011
@@ -46,4 +46,5 @@ class FileDescriptorFactory
     {
         return newFileDescriptor(-1, handle);
     }
+    
 }

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java?rev=1092786&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java Fri
Apr 15 18:53:39 2011
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+import java.io.FileDescriptor;
+
+class Utils
+{
+    private Utils()
+    {
+        // No instance.
+    }
+
+    private static native int   getFd0(FileDescriptor fd);
+    private static native long  getFd1(FileDescriptor fd);
+
+    public static int getFd(FileDescriptor fd)
+        throws NullPointerException
+    {
+        if (fd == null)
+            throw new NullPointerException();
+        return getFd0(fd);
+    }
+
+    public static long getHandle(FileDescriptor fd)
+        throws NullPointerException
+    {
+        if (fd == null)
+            throw new NullPointerException();
+        return getFd1(fd);
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c?rev=1092786&r1=1092785&r2=1092786&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c Fri Apr 15 18:53:39 2011
@@ -192,3 +192,17 @@ ACR_IO_EXPORT(jobject, FileDescriptorFac
 {
     return AcrNewFileDescriptor(env, fd, (acr_osd_t)LLT(fh));
 }
+
+ACR_IO_EXPORT(jint, Utils, getFd0)(JNI_STDARGS, jobject fd)
+{
+    return AcrGetFileDescriptorFd(env, fd);
+}
+
+ACR_IO_EXPORT(jlong, Utils, getFd1)(JNI_STDARGS, jobject fd)
+{
+#if defined (WINDOWS)
+    return P2J(AcrGetFileDescriptorHandle(env, fd));
+#else
+    return 0;
+#endif
+}



Mime
View raw message