You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/07/20 11:44:05 UTC
svn commit: r423857 -
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
Author: pyang
Date: Thu Jul 20 02:44:05 2006
New Revision: 423857
URL: http://svn.apache.org/viewvc?rev=423857&view=rev
Log:
Fix for HARMONY-929 ([classlib][nio]FileChannel.transforTo can use system call to improve efficiency)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c?rev=423857&r1=423856&r2=423857&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSFileSystemWin32.c Thu Jul 20 02:44:05 2006
@@ -210,37 +210,35 @@
(JNIEnv *env, jobject thiz, jlong fd, jobject sd, jlong offset, jlong count)
{
PORT_ACCESS_FROM_ENV (env);
- int length =0;
- HANDLE hfile = (HANDLE)fd;
- OVERLAPPED overlapped;
+ HANDLE hfile = (HANDLE)fd;
SOCKET socket;
- //TODO IPV6
-
- hysocket_t hysocketP = getJavaIoFileDescriptorContentsAsPointer(env,sd);
- if (!hysock_socketIsValid (hysocketP)){
- printf("not valid socket\n");
+ hysocket_t hysocketP;
+ DWORD pos_high = 0;
+ DWORD pos_low = 0;
+
+ if(0 !=(count>>31)) {
+ count = 0x7FFFFFFF;
}
- printf("hysocketP:%p\n",hysocketP);
- if(hysocketP == NULL)
- {
- printf("Error getJavaIoFileDescriptorContentsAsPointer!\n");
- return -1;}
-
- socket = (SOCKET)hysocketP->ipv4;
- printf("socket:%p\n",socket);
- overlapped.Offset = (int)offset;
- overlapped.OffsetHigh = (int)(offset>>32);
- TransmitFile(socket,hfile,(int)count,0,&overlapped,NULL,0);
- printf("TrasmitFile Error %d\n",GetLastError());
- if(GetOverlappedResult((HANDLE)socket,&overlapped,(LPDWORD)&length,1))
- {
- return length; //OK
+ hysocketP = getJavaIoFileDescriptorContentsAsPointer(env,sd);
+ socket = (SOCKET)hysocketP->ipv4;
+
+ pos_low = SetFilePointer(hfile,0,&pos_high,FILE_CURRENT);
+ if(INVALID_SET_FILE_POINTER == pos_low){
+ return -1;
+ }
+
+ if(INVALID_SET_FILE_POINTER == SetFilePointer(hfile,(DWORD)offset,(DWORD *)(((BYTE *)&offset)+4),FILE_BEGIN)){
+ return -1;
}
- else
- {
- printf("GetOverlappedResult Error %d\n",GetLastError());
- return -1;//ERROR
+
+ if(!TransmitFile(socket,hfile,(DWORD)count,0,NULL,NULL,0)){
+ return -1;
+ }
+
+ if(INVALID_SET_FILE_POINTER == SetFilePointer(hfile,pos_low,&pos_high,FILE_BEGIN)){
+ return -1;
}
+ return count;
}