< prev index next >

src/java.base/share/native/libjava/RandomAccessFile.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2013, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 101,127 **** return ret; } JNIEXPORT jlong JNICALL Java_java_io_RandomAccessFile_length(JNIEnv *env, jobject this) { FD fd; ! jlong cur = jlong_zero; ! jlong end = jlong_zero; fd = GET_FD(this, raf_fd); if (fd == -1) { JNU_ThrowIOException(env, "Stream Closed"); return -1; } ! if ((cur = IO_Lseek(fd, 0L, SEEK_CUR)) == -1) { ! JNU_ThrowIOExceptionWithLastError(env, "Seek failed"); ! } else if ((end = IO_Lseek(fd, 0L, SEEK_END)) == -1) { ! JNU_ThrowIOExceptionWithLastError(env, "Seek failed"); ! } else if (IO_Lseek(fd, cur, SEEK_SET) == -1) { ! JNU_ThrowIOExceptionWithLastError(env, "Seek failed"); } ! return end; } JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_seek0(JNIEnv *env, jobject this, jlong pos) { --- 101,123 ---- return ret; } JNIEXPORT jlong JNICALL Java_java_io_RandomAccessFile_length(JNIEnv *env, jobject this) { + FD fd; ! jlong length = jlong_zero; fd = GET_FD(this, raf_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 void JNICALL Java_java_io_RandomAccessFile_seek0(JNIEnv *env, jobject this, jlong pos) {
< prev index next >