harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r937992 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src/main: java/org/apache/harmony/luni/platform/ native/luni/unix/ native/luni/windows/
Date Mon, 26 Apr 2010 10:42:07 GMT
Author: hindessm
Date: Mon Apr 26 10:42:07 2010
New Revision: 937992

URL: http://svn.apache.org/viewvc?rev=937992&view=rev
Log:
Refactor size to single native method rather than three seek calls.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/exports.txt
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java?rev=937992&r1=937991&r2=937992&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/IFileSystem.java
Mon Apr 26 10:42:07 2010
@@ -105,6 +105,8 @@ public interface IFileSystem {
     public long ttyAvailable() throws IOException;
 
     public long available(long fileDescriptor) throws IOException;
+
+    public long size(long fileDescriptor) throws IOException;
     
     public long ttyRead(byte[] bytes, int offset, int length) throws IOException;
 }

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java?rev=937992&r1=937991&r2=937992&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
Mon Apr 26 10:42:07 2010
@@ -277,6 +277,16 @@ class OSFileSystem implements IFileSyste
 
     private native long availableImpl(long fileDescriptor);
 
+    public long size(long fileDescriptor) throws IOException {
+        long nChar = sizeImpl(fileDescriptor);
+        if (nChar < 0) {
+            throw new IOException();
+        }
+        return nChar;
+    }
+
+    private native long sizeImpl(long fileDescriptor);
+
     public long ttyRead(byte[] bytes, int offset, int length) throws IOException {
         long nChar = ttyReadImpl(bytes, offset, length);
         if (nChar < 0) {

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c?rev=937992&r1=937991&r2=937992&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c
Mon Apr 26 10:42:07 2010
@@ -338,3 +338,31 @@ JNIEXPORT jlong JNICALL Java_org_apache_
 #endif
 #endif
 }
+
+
+/*
+ * Answers the size of the file pointed to by the file descriptor.
+ *
+ * Class:     org_apache_harmony_luni_platform_OSFileSystem
+ * Method:    sizeImpl
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_luni_platform_OSFileSystem_sizeImpl
+(JNIEnv *env, jobject thiz, jlong fd)
+{
+    jlong currentPosition =
+      Java_org_apache_harmony_luni_platform_OSFileSystem_seekImpl(env,
+          thiz, fd, 0,
+          org_apache_harmony_luni_platform_IFileSystem_SEEK_CUR);
+
+    jlong endPosition =
+      Java_org_apache_harmony_luni_platform_OSFileSystem_seekImpl(env,
+          thiz, fd, 0,
+          org_apache_harmony_luni_platform_IFileSystem_SEEK_END);
+    
+    Java_org_apache_harmony_luni_platform_OSFileSystem_seekImpl(env,
+          thiz, fd, currentPosition,
+          org_apache_harmony_luni_platform_IFileSystem_SEEK_SET);
+    
+    return (jlong) endPosition;
+}

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/exports.txt?rev=937992&r1=937991&r2=937992&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/exports.txt
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/exports.txt
Mon Apr 26 10:42:07 2010
@@ -138,6 +138,7 @@ Java_org_apache_harmony_luni_platform_OS
 Java_org_apache_harmony_luni_platform_OSFileSystem_transferImpl
 Java_org_apache_harmony_luni_platform_OSFileSystem_ttyAvailableImpl
 Java_org_apache_harmony_luni_platform_OSFileSystem_availableImpl
+Java_org_apache_harmony_luni_platform_OSFileSystem_sizeImpl
 Java_org_apache_harmony_luni_platform_OSFileSystem_ttyReadImpl
 Java_org_apache_harmony_luni_platform_OSMemory_isLoadedImpl
 Java_org_apache_harmony_luni_platform_OSMemory_loadImpl

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c?rev=937992&r1=937991&r2=937992&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
Mon Apr 26 10:42:07 2010
@@ -296,3 +296,29 @@ JNIEXPORT jlong JNICALL Java_org_apache_
     return count;	
 }
 
+/*
+ * Answers the size of the file pointed to by the file descriptor.
+ *
+ * Class:     org_apache_harmony_luni_platform_OSFileSystem
+ * Method:    sizeImpl
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_luni_platform_OSFileSystem_sizeImpl
+(JNIEnv *env, jobject thiz, jlong fd)
+{
+    jlong currentPosition =
+      Java_org_apache_harmony_luni_platform_OSFileSystem_seekImpl(env,
+          thiz, fd, 0,
+          org_apache_harmony_luni_platform_IFileSystem_SEEK_CUR);
+
+    jlong endPosition =
+      Java_org_apache_harmony_luni_platform_OSFileSystem_seekImpl(env,
+          thiz, fd, 0,
+          org_apache_harmony_luni_platform_IFileSystem_SEEK_END);
+    
+    Java_org_apache_harmony_luni_platform_OSFileSystem_seekImpl(env,
+          thiz, fd, currentPosition,
+          org_apache_harmony_luni_platform_IFileSystem_SEEK_SET);
+    
+    return (jlong) endPosition;
+}



Mime
View raw message