X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2FFileIO.java;h=c5480d86ec6c636233b5e5b21d8d5e688f319966;hp=aa71732855bab8a6108d9fa2d837ebb3798a2839;hb=d9a9d77c7024260e3e3b3a8558ddc84b2a8b99b3;hpb=0144ba232323a0e4f7ec8fe0681a150faafd7caf diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java index aa7173285..c5480d86e 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/FileIO.java @@ -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); + + 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 {