This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
RandomAccessFile.seek
- To: java-patches at gcc dot gnu dot org
- Subject: RandomAccessFile.seek
- From: Tony Kimball <alk at pobox dot com>
- Date: Thu, 19 Jul 2001 17:52:05 -0500
- Reply-To: alk at pobox dot com
RandomAccessFile.seek should be able to extend files, instead of
throwing EOFException, to be like JDK 1.3. This patch moves the check
on FileDescriptor.seek up into FileInputStream, so that it does not
occur when RandomAccessFile.seek calls FileDescriptor.seek.
Index: java/io/natFileDescriptorPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorPosix.cc,v
retrieving revision 1.14
diff -u -r1.14 natFileDescriptorPosix.cc
--- natFileDescriptorPosix.cc 2001/06/26 03:27:57 1.14
+++ natFileDescriptorPosix.cc 2001/07/19 22:49:57
@@ -184,9 +184,6 @@
jlong len = length ();
jlong here = getFilePointer ();
- if ((whence == SET && pos > len) || (whence == CUR && here + pos > len))
- throw new EOFException;
-
off_t r = ::lseek (fd, (off_t) pos, whence == SET ? SEEK_SET : SEEK_CUR);
if (r == -1)
throw new IOException (JvNewStringLatin1 (strerror (errno)));
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileInputStream.java,v
retrieving revision 1.5
diff -u -r1.5 FileInputStream.java
--- FileInputStream.java 2000/12/08 10:28:32 1.5
+++ FileInputStream.java 2001/07/19 22:49:57
@@ -88,6 +88,11 @@
public long skip(long n) throws IOException
{
+ long ptr = fd.getFilePointer();
+ long len = fd.length();
+ if ((n > 0) && ((ptr + n) > len))
+ throw new EOFException();
+
return fd.seek(n, FileDescriptor.CUR);
}
}