Chromium Code Reviews| Index: base/android/java/src/org/chromium/base/FileUtilities.java |
| diff --git a/base/android/java/src/org/chromium/base/FileUtilities.java b/base/android/java/src/org/chromium/base/FileUtilities.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a09f362ff520917fb3299bb6a12ed91312dcc966 |
| --- /dev/null |
| +++ b/base/android/java/src/org/chromium/base/FileUtilities.java |
| @@ -0,0 +1,34 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.base; |
| + |
| +import java.io.File; |
| + |
| +/** |
| + * Helper methods for dealing with Files. |
| + */ |
| +public class FileUtilities { |
|
Lalit Maganti
2015/09/22 17:21:58
Out of curiousity: why Utilities in full? In Java
gone
2015/09/22 18:49:56
Former internal repo wonkiness... Renamed this one
|
| + private static final String TAG = "FileUtilities"; |
| + |
| + /** |
| + * Delete the given File and (if it's a directory) everything within it. |
| + */ |
| + public static void recursivelyDeleteFile(File currentFile) { |
| + if (currentFile.isDirectory()) { |
| + File[] files = currentFile.listFiles(); |
| + if (files != null) { |
| + for (File file : files) { |
| + recursivelyDeleteFile(file); |
| + } |
| + } |
| + } |
| + |
| + try { |
| + if (!currentFile.delete()) Log.e(TAG, "Failed to delete: " + currentFile); |
| + } catch (SecurityException e) { |
| + Log.e(TAG, "Hit SecurityException when trying to delete: " + currentFile, e); |
| + } |
| + } |
| +} |