mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8264777: Overload optimized FileInputStream::readAllBytes
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
3b11d811a2
commit
da4dfde71a
4 changed files with 243 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -72,6 +72,39 @@ Java_java_io_FileInputStream_readBytes(JNIEnv *env, jobject this,
|
|||
return readBytes(env, this, bytes, off, len, fis_fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_io_FileInputStream_length0(JNIEnv *env, jobject this) {
|
||||
|
||||
FD fd;
|
||||
jlong length = jlong_zero;
|
||||
|
||||
fd = getFD(env, this, fis_fd);
|
||||
if (fd == -1) {
|
||||
JNU_ThrowIOException(env, "Stream Closed");
|
||||
return -1;
|
||||
}
|
||||
if ((length = IO_GetLength(fd)) == -1) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "GetLength failed");
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_io_FileInputStream_position0(JNIEnv *env, jobject this) {
|
||||
FD fd;
|
||||
jlong ret;
|
||||
|
||||
fd = getFD(env, this, fis_fd);
|
||||
if (fd == -1) {
|
||||
JNU_ThrowIOException(env, "Stream Closed");
|
||||
return -1;
|
||||
}
|
||||
if ((ret = IO_Lseek(fd, 0L, SEEK_CUR)) == -1) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "Seek failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_java_io_FileInputStream_skip0(JNIEnv *env, jobject this, jlong toSkip) {
|
||||
jlong cur = jlong_zero;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue