diff options
Diffstat (limited to 'libjava/java/io/natFileDescriptorPosix.cc')
| -rw-r--r-- | libjava/java/io/natFileDescriptorPosix.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libjava/java/io/natFileDescriptorPosix.cc b/libjava/java/io/natFileDescriptorPosix.cc index 4e05cfe1df3..ad1c1cdd048 100644 --- a/libjava/java/io/natFileDescriptorPosix.cc +++ b/libjava/java/io/natFileDescriptorPosix.cc @@ -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) |
