harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r938022 - /harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c
Date Mon, 26 Apr 2010 12:41:30 GMT
Author: hindessm
Date: Mon Apr 26 12:41:30 2010
New Revision: 938022

URL: http://svn.apache.org/viewvc?rev=938022&view=rev
Log:
Change size call to use fstat.  If we can change the windows natives,
then we can remove:

  synchronized (repositioningLock) { ... }

from FileChannelImpl.size() which I think would be a good idea.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/native/luni/unix/OSFileSystemLinux32.c

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=938022&r1=938021&r2=938022&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 12:41:30 2010
@@ -23,6 +23,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <sys/stat.h>
 #if defined(FREEBSD) || defined(AIX) || defined(ZOS) || defined(MACOSX)
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -350,19 +351,9 @@ JNIEXPORT jlong JNICALL Java_org_apache_
 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;
+  struct stat statbuf;
+  if (fstat(fd - FD_BIAS, &statbuf) < 0) {
+    return -1;
+  }
+  return (jlong)statbuf.st_size;
 }



Mime
View raw message