diff options
Diffstat (limited to 'external/ikvm/openjdk/java/io/FileOutputStream.java')
-rw-r--r-- | external/ikvm/openjdk/java/io/FileOutputStream.java | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/external/ikvm/openjdk/java/io/FileOutputStream.java b/external/ikvm/openjdk/java/io/FileOutputStream.java index e931fe6823..dae9d4bc5e 100644 --- a/external/ikvm/openjdk/java/io/FileOutputStream.java +++ b/external/ikvm/openjdk/java/io/FileOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ package java.io; import java.nio.channels.FileChannel; import sun.nio.ch.FileChannelImpl; +import sun.misc.IoTrace; /** @@ -58,6 +59,11 @@ class FileOutputStream extends OutputStream private final FileDescriptor fd; /** + * The path of the referenced file (null if the stream is created with a file descriptor) + */ + private final String path; + + /** * True if the file is opened for append. */ private final boolean append; @@ -205,9 +211,14 @@ class FileOutputStream extends OutputStream if (name == null) { throw new NullPointerException(); } + /* + if (file.isInvalid()) { + throw new FileNotFoundException("Invalid file path"); + } + */ this.fd = new FileDescriptor(); this.append = append; - + this.path = name; fd.incrementAndGetUseCount(); open(name, append); } @@ -244,6 +255,7 @@ class FileOutputStream extends OutputStream security.checkWrite(fdObj); } this.fd = fdObj; + this.path = null; this.append = false; /* @@ -287,7 +299,14 @@ class FileOutputStream extends OutputStream * @exception IOException if an I/O error occurs. */ public void write(int b) throws IOException { - write(b, append); + Object traceContext = IoTrace.fileWriteBegin(path); + int bytesWritten = 0; + try { + write(b, append); + bytesWritten = 1; + } finally { + IoTrace.fileWriteEnd(traceContext, bytesWritten); + } } /** @@ -312,7 +331,14 @@ class FileOutputStream extends OutputStream * @exception IOException if an I/O error occurs. */ public void write(byte b[]) throws IOException { - writeBytes(b, 0, b.length, append); + Object traceContext = IoTrace.fileWriteBegin(path); + int bytesWritten = 0; + try { + writeBytes(b, 0, b.length, append); + bytesWritten = b.length; + } finally { + IoTrace.fileWriteEnd(traceContext, bytesWritten); + } } /** @@ -325,7 +351,14 @@ class FileOutputStream extends OutputStream * @exception IOException if an I/O error occurs. */ public void write(byte b[], int off, int len) throws IOException { - writeBytes(b, off, len, append); + Object traceContext = IoTrace.fileWriteBegin(path); + int bytesWritten = 0; + try { + writeBytes(b, off, len, append); + bytesWritten = len; + } finally { + IoTrace.fileWriteEnd(traceContext, bytesWritten); + } } /** @@ -408,7 +441,7 @@ class FileOutputStream extends OutputStream public FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, false, true, append, this); + channel = FileChannelImpl.open(fd, path, false, true, append, this); /* * Increment fd's use count. Invoking the channel's close() |