Mercurial > hg4j
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 635:4ec2d44e2bf3 | 636:ffce73efa2c2 |
|---|---|
| 75 fos = null; | 75 fos = null; |
| 76 fis.close(); | 76 fis.close(); |
| 77 fis = null; | 77 fis = null; |
| 78 } catch (IOException ex) { | 78 } catch (IOException ex) { |
| 79 // not in finally because I don't want to loose exception from fos.close() | 79 // not in finally because I don't want to loose exception from fos.close() |
| 80 closeQuietly(fis); | 80 closeQuietly(fis, from); |
| 81 closeQuietly(fos); | 81 closeQuietly(fos, to); |
| 82 String m = String.format("Failed to copy %s to %s", from.getName(), to.getName()); | 82 String m = String.format("Failed to copy %s to %s", from.getName(), to.getName()); |
| 83 throw new HgIOException(m, ex, from); | 83 throw new HgIOException(m, ex, from); |
| 84 } | 84 } |
| 85 /* Copy of cpython's 00changelog.d, 20Mb+ | 85 /* Copy of cpython's 00changelog.d, 20Mb+ |
| 86 * Linux&Windows: 300-400 ms, | 86 * Linux&Windows: 300-400 ms, |
| 87 * Windows uncached run: 1.6 seconds | 87 * Windows uncached run: 1.6 seconds |
| 88 */ | 88 */ |
| 89 } | 89 } |
| 90 | 90 |
| 91 public void closeQuietly(Closeable stream) { | 91 public void closeQuietly(Closeable stream) { |
| 92 closeQuietly(stream, null); | |
| 93 } | |
| 94 | |
| 95 public void closeQuietly(Closeable stream, File f) { | |
| 92 if (stream != null) { | 96 if (stream != null) { |
| 93 try { | 97 try { |
| 94 stream.close(); | 98 stream.close(); |
| 95 } catch (IOException ex) { | 99 } catch (IOException ex) { |
| 96 // ignore | 100 // ignore |
| 97 log.dump(getClass(), Severity.Warn, ex, "Exception while closing stream quietly"); | 101 final String msg; |
| 102 if (f == null) { | |
| 103 msg = "Exception while closing stream quietly"; | |
| 104 } else { | |
| 105 msg = String.format("Failed to close %s", f); | |
| 106 } | |
| 107 log.dump(getClass(), Severity.Warn, ex, msg); | |
| 98 } | 108 } |
| 99 } | 109 } |
| 100 } | 110 } |
| 101 } | 111 } |
