[m-rev.] diff: fix io.open_binary_output in java

Peter Wang novalazy at gmail.com
Wed Aug 5 15:01:14 AEST 2009


Branches: main

library/io.m:
        Make Java implementation of io.open_binary_output truncate existing
        files.

diff --git a/library/io.m b/library/io.m
index 93e59bc..c7f3c3e 100644
--- a/library/io.m
+++ b/library/io.m
@@ -5744,7 +5744,10 @@ namespace mercury {
             }
             try {
                 randomaccess = new java.io.RandomAccessFile(file, openstring);
-                if (mode == 'a') {
+                if (mode == 'w') {
+                    // Truncate an existing file.
+                    randomaccess.setLength(0);
+                } else if (mode == 'a') {
                     seek(SEEK_END, 0);
                 }
             } catch (java.lang.Exception e) {

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list