Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 952 invoked from network); 15 Apr 2011 18:54:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Apr 2011 18:54:03 -0000 Received: (qmail 95352 invoked by uid 500); 15 Apr 2011 18:54:03 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 95303 invoked by uid 500); 15 Apr 2011 18:54:03 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 95296 invoked by uid 99); 15 Apr 2011 18:54:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Apr 2011 18:54:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Apr 2011 18:54:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BA21523889DA; Fri, 15 Apr 2011 18:53:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110415185339.BA21523889DA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 +}