diff options
author | Jean-Philippe Lesot <jplesot@google.com> | 2015-03-12 23:23:34 +0100 |
---|---|---|
committer | Jean-Philippe Lesot <jplesot@google.com> | 2015-03-13 17:11:00 +0100 |
commit | 2282698f8fc035c0722225931ead9c653d95e202 (patch) | |
tree | 756aae5cd388a3c75b0b6b848ef08daf97fd8c2e /sched/src/com/android/sched | |
parent | 8007ff78c3d693f7a17350fae567ae5e6e0f0fb2 (diff) | |
download | toolchain_jack-2282698f8fc035c0722225931ead9c653d95e202.tar.gz toolchain_jack-2282698f8fc035c0722225931ead9c653d95e202.tar.bz2 toolchain_jack-2282698f8fc035c0722225931ead9c653d95e202.zip |
Add property to set an output file by reporter level
Bug: 19715777
Change-Id: Ic729dc387f6ac7b95068f864ae44cf63f0469a90
Diffstat (limited to 'sched/src/com/android/sched')
-rw-r--r-- | sched/src/com/android/sched/util/file/InputStreamFile.java | 15 | ||||
-rw-r--r-- | sched/src/com/android/sched/util/file/OutputStreamFile.java | 33 |
2 files changed, 23 insertions, 25 deletions
diff --git a/sched/src/com/android/sched/util/file/InputStreamFile.java b/sched/src/com/android/sched/util/file/InputStreamFile.java index 179da191..1aa3b4fe 100644 --- a/sched/src/com/android/sched/util/file/InputStreamFile.java +++ b/sched/src/com/android/sched/util/file/InputStreamFile.java @@ -35,7 +35,7 @@ import javax.annotation.Nonnull; */ public class InputStreamFile extends AbstractStreamFile { @CheckForNull - private InputStream in; + private InputStream stream; public InputStreamFile(@Nonnull String name) throws WrongPermissionException, NotFileException, NoSuchFileException { @@ -44,12 +44,12 @@ public class InputStreamFile extends AbstractStreamFile { public InputStreamFile() { super(new StandardInputLocation()); - in = System.in; + stream = new UncloseableInputStream(System.in); } public InputStreamFile(@Nonnull InputStream in, @Nonnull Location location) { super(location); - this.in = in; + this.stream = new UncloseableInputStream(in); } public InputStreamFile(@CheckForNull Directory workingDirectory, @Nonnull String string) @@ -74,15 +74,16 @@ public class InputStreamFile extends AbstractStreamFile { @Nonnull public InputStream getInputStream() { - if (in != null) { - return new UncloseableInputStream(in); - } else { + if (stream == null) { clearRemover(); + try { - return new FileInputStream(file); + stream = new FileInputStream(file); } catch (FileNotFoundException e) { throw new ConcurrentIOException(e); } } + + return stream; } }
\ No newline at end of file diff --git a/sched/src/com/android/sched/util/file/OutputStreamFile.java b/sched/src/com/android/sched/util/file/OutputStreamFile.java index 17644e0a..0b78ebbb 100644 --- a/sched/src/com/android/sched/util/file/OutputStreamFile.java +++ b/sched/src/com/android/sched/util/file/OutputStreamFile.java @@ -22,7 +22,6 @@ import com.android.sched.util.location.FileLocation; import com.android.sched.util.location.Location; import com.android.sched.util.location.StandardErrorLocation; import com.android.sched.util.location.StandardOutputLocation; -import com.android.sched.util.stream.UncloseableOutputStream; import com.android.sched.util.stream.UncloseablePrintStream; import java.io.File; @@ -42,6 +41,8 @@ public class OutputStreamFile extends AbstractStreamFile { @CheckForNull private PrintStream printer; + @CheckForNull + private OutputStream stream; public OutputStreamFile(@Nonnull String name, @CheckForNull RunnableHooks hooks, @@ -157,7 +158,7 @@ public class OutputStreamFile extends AbstractStreamFile { @Override @Nonnull public PrintStream getPrintStream() { - return System.out; + return new UncloseablePrintStream(System.out); } @Override @@ -171,7 +172,7 @@ public class OutputStreamFile extends AbstractStreamFile { @Override @Nonnull public PrintStream getPrintStream() { - return System.err; + return new UncloseablePrintStream(System.err); } @Override @@ -196,35 +197,31 @@ public class OutputStreamFile extends AbstractStreamFile { public OutputStreamFile(@Nonnull PrintStream printer, @Nonnull Location location) { super(location); - this.printer = printer; + this.printer = new UncloseablePrintStream(printer); this.append = true; } @Nonnull public OutputStream getOutputStream() { - if (printer != null) { - return new UncloseableOutputStream(printer); - } else { + if (stream == null) { clearRemover(); + try { - return new FileOutputStream(file, append); + stream = new FileOutputStream(file, append); } catch (FileNotFoundException e) { throw new ConcurrentIOException(e); } } + + return stream; } @Nonnull public PrintStream getPrintStream() { - if (printer != null) { - return new UncloseablePrintStream(printer); - } else { - clearRemover(); - try { - return new PrintStream(file); - } catch (FileNotFoundException e) { - throw new ConcurrentIOException(e); - } + if (printer == null) { + printer = new PrintStream(getOutputStream()); } + + return printer; } -}
\ No newline at end of file +} |