]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java
Acorn: Fix WriteRunnable.runReally() and other fixes
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / FileIO.java
index aa71732855bab8a6108d9fa2d837ebb3798a2839..c5480d86ec6c636233b5e5b21d8d5e688f319966 100644 (file)
@@ -66,15 +66,17 @@ public class FileIO {
                ByteBuffer bb = ByteBuffer.wrap(bytes, 0, length);
                try (FileChannel fc = FileChannel.open(path, options, NO_ATTRIBUTES)) {
             fc.write(bb);
                ByteBuffer bb = ByteBuffer.wrap(bytes, 0, length);
                try (FileChannel fc = FileChannel.open(path, options, NO_ATTRIBUTES)) {
             fc.write(bb);
+            
+            writePosition += length;
+            if(TRACE_PERF) {
+                long duration = System.nanoTime()-start;
+                double ds = 1e-9*duration;
+                System.err.println("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
+            }
+            return result;
+               } catch (Throwable t) {
+                   throw new IOException("An error occured file saving bytes for file " + path.toAbsolutePath().toString(), t);
                }
                }
-               
-        writePosition += length;
-               if(TRACE_PERF) {
-                       long duration = System.nanoTime()-start;
-                       double ds = 1e-9*duration;
-                       System.err.println("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
-               }
-               return result;
        }
 
     public synchronized byte[] readBytes(int offset, int length) throws IOException {
        }
 
     public synchronized byte[] readBytes(int offset, int length) throws IOException {