RandomAccessFile.java (seek): Let seek go past end of file.

* java/io/RandomAccessFile.java (seek): Let seek go past end of
	file.
	(skipBytes): Don't fail if seeking past end of file.
	* java/io/FileInputStream.java (skip): Don't fail if seeking past
	end of file.
	* java/io/natFileDescriptorWin32.cc (seek): Handle `eof_trunc'
	argument.
	* java/io/natFileDescriptorEcos.cc (seek): Handle `eof_trunc'
	argument.
	* java/io/natFileDescriptorPosix.cc (seek): Handle `eof_trunc'
	argument.
	* java/io/FileDescriptor.java (seek): Added `eof_trunc' argument.

From-SVN: r44586
This commit is contained in:
Tom Tromey
2001-08-02 23:46:39 +00:00
committed by Tom Tromey
parent ead4cf347a
commit 8d6a437584
7 changed files with 43 additions and 23 deletions
+7 -3
View File
@@ -177,15 +177,19 @@ java::io::FileDescriptor::close (void)
}
jint
java::io::FileDescriptor::seek (jlong pos, jint whence)
java::io::FileDescriptor::seek (jlong pos, jint whence, jboolean eof_trunc)
{
JvAssert (whence == SET || whence == CUR);
jlong len = length ();
jlong here = getFilePointer ();
if ((whence == SET && pos > len) || (whence == CUR && here + pos > len))
throw new EOFException;
if (eof_trunc
&& ((whence == SET && pos > len) || (whence == CUR && here + pos > len)))
{
whence = SET;
pos = len;
}
off_t r = ::lseek (fd, (off_t) pos, whence == SET ? SEEK_SET : SEEK_CUR);
if (r == -1)