Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
align eoffh on jvm to moar/parrot
So we recognize EOF right at EOF from a user perspective.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| public class FileHandle extends SyncHandle implements IIOSeekable { | ||
|
|
||
| FileChannel fc; | ||
| protected boolean eof = false; | ||
|
|
||
| public FileHandle(ThreadContext tc, String filename, String mode) { | ||
| try { | ||
|
|
@@ -78,4 +79,24 @@ public void flush(ThreadContext tc) { | |
| throw ExceptionHandling.dieInternal(tc, e); | ||
| } | ||
| } | ||
|
|
||
| public boolean eof(ThreadContext tc) { | ||
| if (eof) | ||
| return true; | ||
| else if (readBuffer != null && readBuffer.remaining() > 0) | ||
| return false; | ||
| else { | ||
| try { | ||
| long position = fc.position(); | ||
| getc(tc); | ||
| fc.position(position); | ||
| readBuffer = null; | ||
| return false; | ||
| } | ||
| catch (Exception e) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
teodozjan
Contributor
|
||
| eof = true; | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
this should probably catch the specific exception.