543 |
return (-1); |
return (-1); |
544 |
} |
} |
545 |
} |
} |
546 |
while (bytes_read != 1); |
while (result != TARGET_NATIVE_OK); |
547 |
|
|
548 |
return ((jint) (data & 0xFF)); |
return ((jint) (data & 0xFF)); |
549 |
} |
} |
571 |
if (length == 0) |
if (length == 0) |
572 |
return 0; |
return 0; |
573 |
|
|
574 |
|
if (offset < 0) |
575 |
|
{ |
576 |
|
JCL_ThrowException (env, IO_EXCEPTION, "negative offset"); |
577 |
|
return -1; |
578 |
|
} |
579 |
|
|
580 |
bufptr = (*env)->GetByteArrayElements (env, buffer, 0); |
bufptr = (*env)->GetByteArrayElements (env, buffer, 0); |
581 |
if (!bufptr) |
if (!bufptr) |
582 |
{ |
{ |
584 |
return (-1); |
return (-1); |
585 |
} |
} |
586 |
|
|
587 |
|
if (length + offset > (*env)->GetArrayLength (env, buffer)) |
588 |
|
{ |
589 |
|
JCL_ThrowException (env, IO_EXCEPTION, |
590 |
|
"length + offset > buffer.length"); |
591 |
|
return -1; |
592 |
|
} |
593 |
|
|
594 |
bytes_read = 0; |
bytes_read = 0; |
595 |
do |
do |
596 |
{ |
{ |
613 |
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0); |
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0); |
614 |
return -1; |
return -1; |
615 |
} |
} |
616 |
bytes_read += n; |
if (result == TARGET_NATIVE_OK) |
617 |
|
bytes_read += n; |
618 |
} |
} |
619 |
while (bytes_read < 1); |
while (bytes_read < 1); |
620 |
|
|
648 |
{ |
{ |
649 |
JCL_ThrowException (env, IO_EXCEPTION, |
JCL_ThrowException (env, IO_EXCEPTION, |
650 |
TARGET_NATIVE_LAST_ERROR_STRING ()); |
TARGET_NATIVE_LAST_ERROR_STRING ()); |
651 |
|
return; |
652 |
} |
} |
653 |
} |
} |
654 |
while (result != TARGET_NATIVE_OK); |
while (result != TARGET_NATIVE_OK); |
655 |
} |
} |
656 |
|
|
657 |
/* |
/* |
658 |
|
* Copies all parts of a file to disk. |
659 |
|
*/ |
660 |
|
JNIEXPORT void JNICALL |
661 |
|
Java_gnu_java_nio_channels_FileChannelImpl_force (JNIEnv * env, |
662 |
|
jobject obj) |
663 |
|
{ |
664 |
|
int native_fd; |
665 |
|
int result; |
666 |
|
native_fd = get_native_fd (env, obj); |
667 |
|
TARGET_NATIVE_FILE_FSYNC (native_fd, result); |
668 |
|
if (result != TARGET_NATIVE_OK) |
669 |
|
JCL_ThrowException (env, IO_EXCEPTION, |
670 |
|
TARGET_NATIVE_LAST_ERROR_STRING ()); |
671 |
|
} |
672 |
|
|
673 |
|
/* |
674 |
* Writes a byte buffer to the specified file descriptor |
* Writes a byte buffer to the specified file descriptor |
675 |
* Return status code, exception on error |
* Return status code, exception on error |
676 |
*/ |
*/ |
714 |
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0); |
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0); |
715 |
return; |
return; |
716 |
} |
} |
717 |
bytes_written += n; |
if (result == TARGET_NATIVE_OK) |
718 |
|
bytes_written += n; |
719 |
} |
} |
720 |
|
|
721 |
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0); |
(*env)->ReleaseByteArrayElements (env, buffer, bufptr, 0); |