1) bug fix on nativeavailable(): forgot to get back the file pointer to the current...
authoryeom <yeom>
Mon, 15 Aug 2011 18:08:18 +0000 (18:08 +0000)
committeryeom <yeom>
Mon, 15 Aug 2011 18:08:18 +0000 (18:08 +0000)
2) small optimization on the FileInputStream.

Robust/src/ClassLibrary/SSJava/FileInputStream.java
Robust/src/Runtime/file.c

index be3c76f4c479d4d1cbaf20a64746be8d7587738c..8dfd3fe8b2d27ce72442b853da774a7041c96715 100644 (file)
@@ -48,9 +48,7 @@ public class FileInputStream extends InputStream {
     }
     byte readbuf[] = new byte[len];
     int rtr = nativeRead(fd, readbuf, len);
     }
     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;
   }
 
     return rtr;
   }
 
index c8997a10601eff191ac8571c45fde704a8ad2b3b..0eb7d901d1628489da087b24d6147c72aca19916 100644 (file)
@@ -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);
   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
   avail=fsize-cur;
   return avail;
 #endif