From be34eec682d9c5a81206b8172032b3154ad57210 Mon Sep 17 00:00:00 2001 From: yeom Date: Mon, 15 Aug 2011 18:08:18 +0000 Subject: [PATCH] 1) bug fix on nativeavailable(): forgot to get back the file pointer to the current position. 2) small optimization on the FileInputStream. --- Robust/src/ClassLibrary/SSJava/FileInputStream.java | 4 +--- Robust/src/Runtime/file.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Robust/src/ClassLibrary/SSJava/FileInputStream.java b/Robust/src/ClassLibrary/SSJava/FileInputStream.java index be3c76f4..8dfd3fe8 100644 --- a/Robust/src/ClassLibrary/SSJava/FileInputStream.java +++ b/Robust/src/ClassLibrary/SSJava/FileInputStream.java @@ -48,9 +48,7 @@ public class FileInputStream extends InputStream { } byte readbuf[] = new byte[len]; int rtr = nativeRead(fd, readbuf, len); - for (int i = offset; i < len + offset; i++) { - b[i] = readbuf[i - offset]; - } + System.arraycopy(readbuf, 0, b, offset, len); return rtr; } diff --git a/Robust/src/Runtime/file.c b/Robust/src/Runtime/file.c index c8997a10..0eb7d901 100644 --- a/Robust/src/Runtime/file.c +++ b/Robust/src/Runtime/file.c @@ -153,6 +153,7 @@ int CALL11(___FileInputStream______nativeAvailable____I, int fd, int fd) { int avail; int cur=lseek(fd, 0, SEEK_CUR); int fsize = lseek(fd, 0, SEEK_END); + lseek(fd,cur,SEEK_SET); // seek back to the current position avail=fsize-cur; return avail; #endif -- 2.34.1