Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 74241 invoked from network); 3 Oct 2009 10:52:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Oct 2009 10:52:02 -0000 Received: (qmail 78017 invoked by uid 500); 3 Oct 2009 10:52:01 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 77918 invoked by uid 500); 3 Oct 2009 10:52:01 -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 77909 invoked by uid 99); 3 Oct 2009 10:52:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Oct 2009 10:52:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Sat, 03 Oct 2009 10:51:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D85C82388901; Sat, 3 Oct 2009 10:51:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821291 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_file.h os/unix/file.c os/win32/file.c shared/fsysio.c Date: Sat, 03 Oct 2009 10:51:36 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091003105136.D85C82388901@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Sat Oct 3 10:51:35 2009 New Revision: 821291 URL: http://svn.apache.org/viewvc?rev=821291&view=rev Log: Add few more file methods Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h?rev=821291&r1=821290&r2=821291&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h Sat Oct 3 10:51:35 2009 @@ -248,7 +248,7 @@ /** Create temporary unique file. * @param env JNI environment to use. If NULL no exception will be thrown * if stat fails. - * @pamap tmpath Path where to create the file. + * @param tmpath Path where to create the file. * @param prefix File prefix. * @param preserve Non zero to survive file close. * @return File descriptor or -1 o failure. @@ -260,7 +260,7 @@ /** Create temporary unique directory. * @param env JNI environment to use. If NULL no exception will be thrown * if stat fails. - * @pamap tmpath Path where to create the directory. + * @param tmpath Path where to create the directory. * @param prefix Directory prefix. * @return Newly created unique directory path. Use ACR_Free when no longer * needed. Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=821291&r1=821290&r2=821291&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Sat Oct 3 10:51:35 2009 @@ -443,3 +443,31 @@ return attr; } +ACR_IO_EXPORT_DECLARE(jstring, File, tmpdir0)(ACR_JNISTDARGS, jstring path, + jstring prefix) +{ + int rc = 0; + char *tmpd = NULL; + + UNREFERENCED_O; + + WITH_ZCSTR(path) { + WITH_ZCSTR(prefix) { + /* Provide INVALID_HANDLE_VALUE for JNIEnv + * so that in case of failure, exception doesn't get thrown + */ + tmpd = ACR_TempDirMake(INVALID_HANDLE_VALUE, J2S(path), J2S(prefix)); + if (!tmpd) + rc = ACR_GET_OS_ERROR(); + } END_WITH_CSTR(prefix); + } END_WITH_CSTR(path); + if (rc) { + ACR_THROW_IO_IF_ERR(rc); + return NULL; + } + else { + jstring rv = ACR_NewJavaStringA(_E, tmpd); + x_free(tmpd); + return rv; + } +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=821291&r1=821290&r2=821291&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Sat Oct 3 10:51:35 2009 @@ -875,3 +875,31 @@ return attr; } +ACR_IO_EXPORT_DECLARE(jstring, File, tmpdir0)(ACR_JNISTDARGS, jstring path, + jstring prefix) +{ + int rc = 0; + wchar_t *tmpd = NULL; + + UNREFERENCED_O; + + WITH_ZWSTR(path) { + WITH_ZWSTR(prefix) { + /* Provide INVALID_HANDLE_VALUE for JNIEnv + * so that in case of failure, exception doesn't get thrown + */ + tmpd = ACR_TempDirMake(INVALID_HANDLE_VALUE, J2W(path), J2W(prefix)); + if (!tmpd) + rc = ACR_GET_OS_ERROR(); + } END_WITH_WSTR(prefix); + } END_WITH_WSTR(path); + if (rc) { + ACR_THROW_IO_IF_ERR(rc); + return NULL; + } + else { + jstring rv = ACR_NewJavaStringW(_E, tmpd); + x_free(tmpd); + return rv; + } +} Modified: commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c?rev=821291&r1=821290&r2=821291&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c Sat Oct 3 10:51:35 2009 @@ -19,6 +19,7 @@ #include "acr_arch.h" #include "acr_error.h" #include "acr_memory.h" +#include "acr_string.h" #include "acr_descriptor.h" #include "acr_file.h" #include "acr_fileio.h" @@ -56,6 +57,22 @@ return V2Z(f->eof); } +ACR_IO_EXPORT_DECLARE(jboolean, FileWrapper, blocking0)(ACR_JNISTDARGS, + jint file) +{ + acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file); + + if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) { + ACR_THROW_IO_IF_ERR(ACR_EFTYPE); + return JNI_FALSE; + } + if (IS_INVALID_HANDLE(f)) { + ACR_THROW_IO_IF_ERR(ACR_EBADF); + return JNI_FALSE; + } + return f->blocking == BLK_ON ? JNI_TRUE : JNI_FALSE; +} + ACR_IO_EXPORT_DECLARE(jint, FileWrapper, tmset0)(ACR_JNISTDARGS, jint file, jlong timeout) @@ -90,3 +107,19 @@ } return (jlong)f->timeout; } + +ACR_IO_EXPORT_DECLARE(jstring, FileWrapper, name0)(ACR_JNISTDARGS, + jint file) +{ + acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file); + + if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) { + ACR_THROW_IO_IF_ERR(ACR_EFTYPE); + return NULL; + } + if (IS_INVALID_HANDLE(f)) { + ACR_THROW_IO_IF_ERR(ACR_EBADF); + return NULL; + } + return PSTR_TO_JSTRING(f->name); +}