This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FileInputStream.skip() fix


FileInputStream.skip() is supposed to return the actual number of bytes 
skipped, but ours was returning the current position in the file. This 
patch fixes.

Bryce.


    * java/io/FileInputStream.java (skip): Call fd.getFilePointer() and
    calculate correct number of bytes skipped.

Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileInputStream.java,v
retrieving revision 1.6
diff -u -r1.6 FileInputStream.java
--- FileInputStream.java        2001/08/02 23:46:39     1.6
+++ FileInputStream.java        2002/03/25 01:55:26
@@ -88,6 +88,8 @@
 
   public long skip(long n) throws IOException
   {
-    return n <= 0 ? 0 : fd.seek(n, FileDescriptor.CUR, true);
+    long startPos = fd.getFilePointer();
+    long endPos = fd.seek(n, FileDescriptor.CUR, true);
+    return endPos - startPos;
   }
 }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]