< prev index next >

src/java.base/windows/native/libnio/ch/FileChannelImpl.c

Print this page




 148     HANDLE h = (HANDLE)(handleval(env, fdo));
 149     LARGE_INTEGER where;
 150     DWORD whence;
 151 
 152     if (offset < 0) {
 153         where.QuadPart = 0;
 154         whence = FILE_CURRENT;
 155     } else {
 156         where.QuadPart = offset;
 157         whence = FILE_BEGIN;
 158     }
 159 
 160     result = SetFilePointerEx(h, where, &where, whence);
 161     if (result == 0) {
 162         JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
 163         return IOS_THROWN;
 164     }
 165     return (jlong)where.QuadPart;
 166 }
 167 
 168 JNIEXPORT void JNICALL
 169 Java_sun_nio_ch_FileChannelImpl_close0(JNIEnv *env, jobject this, jobject fdo)
 170 {
 171     HANDLE h = (HANDLE)(handleval(env, fdo));
 172     if (h != INVALID_HANDLE_VALUE) {
 173         BOOL result = CloseHandle(h);
 174         if (result == 0) {
 175             JNU_ThrowIOExceptionWithLastError(env, "Close failed");
 176         }
 177     }
 178 }
 179 
 180 JNIEXPORT jlong JNICALL
 181 Java_sun_nio_ch_FileChannelImpl_transferTo0(JNIEnv *env, jobject this,
 182                                             jobject srcFD,
 183                                             jlong position, jlong count,
 184                                             jobject dstFD)
 185 {
 186     const int PACKET_SIZE = 524288;
 187 
 188     HANDLE src = (HANDLE)(handleval(env, srcFD));
 189     SOCKET dst = (SOCKET)(fdval(env, dstFD));
 190     DWORD chunkSize = (count > java_lang_Integer_MAX_VALUE) ?
 191         java_lang_Integer_MAX_VALUE : (DWORD)count;
 192     BOOL result = 0;
 193 
 194     jlong pos = Java_sun_nio_ch_FileChannelImpl_position0(env, this, srcFD, position);
 195     if (pos == IOS_THROWN) {
 196         return IOS_THROWN;
 197     }
 198 
 199     result = TransmitFile(




 148     HANDLE h = (HANDLE)(handleval(env, fdo));
 149     LARGE_INTEGER where;
 150     DWORD whence;
 151 
 152     if (offset < 0) {
 153         where.QuadPart = 0;
 154         whence = FILE_CURRENT;
 155     } else {
 156         where.QuadPart = offset;
 157         whence = FILE_BEGIN;
 158     }
 159 
 160     result = SetFilePointerEx(h, where, &where, whence);
 161     if (result == 0) {
 162         JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
 163         return IOS_THROWN;
 164     }
 165     return (jlong)where.QuadPart;
 166 }
 167 












 168 JNIEXPORT jlong JNICALL
 169 Java_sun_nio_ch_FileChannelImpl_transferTo0(JNIEnv *env, jobject this,
 170                                             jobject srcFD,
 171                                             jlong position, jlong count,
 172                                             jobject dstFD)
 173 {
 174     const int PACKET_SIZE = 524288;
 175 
 176     HANDLE src = (HANDLE)(handleval(env, srcFD));
 177     SOCKET dst = (SOCKET)(fdval(env, dstFD));
 178     DWORD chunkSize = (count > java_lang_Integer_MAX_VALUE) ?
 179         java_lang_Integer_MAX_VALUE : (DWORD)count;
 180     BOOL result = 0;
 181 
 182     jlong pos = Java_sun_nio_ch_FileChannelImpl_position0(env, this, srcFD, position);
 183     if (pos == IOS_THROWN) {
 184         return IOS_THROWN;
 185     }
 186 
 187     result = TransmitFile(


< prev index next >