diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-08-18 18:44:50 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-08-18 18:44:50 +0200 |
| commit | e3bad494f541eb574e80e466ed8abaef8bb5d257 (patch) | |
| tree | f3efbacc2d7c7b8940c5410daab85cd8b4852518 /main/src/cgeo/geocaching/utils/FileUtils.java | |
| parent | 8fd7c4eedabbf77c9d4131503d122c55a23b070f (diff) | |
| download | cgeo-e3bad494f541eb574e80e466ed8abaef8bb5d257.zip cgeo-e3bad494f541eb574e80e466ed8abaef8bb5d257.tar.gz cgeo-e3bad494f541eb574e80e466ed8abaef8bb5d257.tar.bz2 | |
refactoring: fix findbugs issues
Diffstat (limited to 'main/src/cgeo/geocaching/utils/FileUtils.java')
| -rw-r--r-- | main/src/cgeo/geocaching/utils/FileUtils.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/FileUtils.java b/main/src/cgeo/geocaching/utils/FileUtils.java index 0b358d2..fec2518 100644 --- a/main/src/cgeo/geocaching/utils/FileUtils.java +++ b/main/src/cgeo/geocaching/utils/FileUtils.java @@ -89,4 +89,26 @@ public final class FileUtils { private static String getNumberedFileName(String pathName, String extension, int number) { return pathName + (number > 1 ? "_" + Integer.toString(number) : "") + "." + extension; } + + /** + * This usage of this method indicates that the return value of File.delete() can safely be ignored. + */ + public static void deleteIgnoringFailure(final File file) { + if (!file.delete()) { + Log.i("Could not delete " + file.getAbsolutePath()); + } + } + + /** + * Deletes a file and logs deletion failures. + * + * @return <code> true</code> if this file was deleted, <code>false</code> otherwise. + */ + public static boolean delete(final File file) { + final boolean success = file.delete(); + if (!success) { + Log.e("Could not delete " + file.getAbsolutePath()); + } + return success; + } } |
