Mercurial > jhg
diff src/org/tmatesoft/hg/internal/FileUtils.java @ 636:ffce73efa2c2
HgCommitCommand: save last commit message
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 06 Jun 2013 19:39:06 +0200 |
parents | 507602cb4fb3 |
children | 12a4f60ea972 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/FileUtils.java Thu Jun 06 18:42:38 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/FileUtils.java Thu Jun 06 19:39:06 2013 +0200 @@ -77,8 +77,8 @@ fis = null; } catch (IOException ex) { // not in finally because I don't want to loose exception from fos.close() - closeQuietly(fis); - closeQuietly(fos); + closeQuietly(fis, from); + closeQuietly(fos, to); String m = String.format("Failed to copy %s to %s", from.getName(), to.getName()); throw new HgIOException(m, ex, from); } @@ -87,14 +87,24 @@ * Windows uncached run: 1.6 seconds */ } - + public void closeQuietly(Closeable stream) { + closeQuietly(stream, null); + } + + public void closeQuietly(Closeable stream, File f) { if (stream != null) { try { stream.close(); } catch (IOException ex) { // ignore - log.dump(getClass(), Severity.Warn, ex, "Exception while closing stream quietly"); + final String msg; + if (f == null) { + msg = "Exception while closing stream quietly"; + } else { + msg = String.format("Failed to close %s", f); + } + log.dump(getClass(), Severity.Warn, ex, msg); } } }