-
-
Save cygx/795dc8f57e0f5e2606072c3cca650574 to your computer and use it in GitHub Desktop.
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
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/io/FileHandle.java b/src/vm/jvm/runtime/org/perl6/nqp/io/FileHandle.java | |
index 7921efa..a3577d1 100644 | |
--- a/src/vm/jvm/runtime/org/perl6/nqp/io/FileHandle.java | |
+++ b/src/vm/jvm/runtime/org/perl6/nqp/io/FileHandle.java | |
@@ -20,8 +20,9 @@ public class FileHandle extends SyncHandle implements IIOSeekable, IIOLockable { | |
FileChannel fc; | |
FileLock lock; | |
protected boolean eof = false; | |
+ protected boolean append = false; | |
- public static OpenOption[] resolveOpenMode(String mode) { | |
+ protected OpenOption[] resolveOpenMode(String mode) { | |
if(mode.length() == 0) | |
return null; | |
@@ -45,7 +46,7 @@ public class FileHandle extends SyncHandle implements IIOSeekable, IIOLockable { | |
} | |
while (pos < mode.length()) switch (mode.charAt(pos++)) { | |
- case 'a': opts.add(StandardOpenOption.APPEND); break; | |
+ case 'a': append = true; break; | |
case 'c': opts.add(StandardOpenOption.CREATE); break; | |
case 't': opts.add(StandardOpenOption.TRUNCATE_EXISTING); break; | |
case 'x': opts.add(StandardOpenOption.CREATE_NEW); break; | |
@@ -162,4 +163,14 @@ public class FileHandle extends SyncHandle implements IIOSeekable, IIOLockable { | |
} | |
} | |
} | |
+ | |
+ protected long write(ThreadContext tc, ByteBuffer buffer) { | |
+ if(append) try { | |
+ fc.position(fc.size()); | |
+ } | |
+ catch (IOException e) { | |
+ throw ExceptionHandling.dieInternal(tc, e); | |
+ } | |
+ return super.write(tc, buffer); | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment