Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: base/android/java/src/org/chromium/base/FileUtils.java

Issue 1354323003: Fix up _some_web app directory StrictMode violations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Making the class less ugly, hopefully Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/FileUtils.java
diff --git a/base/android/java/src/org/chromium/base/FileUtils.java b/base/android/java/src/org/chromium/base/FileUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff71484d370934dcdd2a2afaa501764c1d2e9bb9
--- /dev/null
+++ b/base/android/java/src/org/chromium/base/FileUtils.java
@@ -0,0 +1,35 @@
+// 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 FileUtils {
+ private static final String TAG = "FileUtils";
+
+ /**
+ * Delete the given File and (if it's a directory) everything within it.
+ */
+ public static void recursivelyDeleteFile(File currentFile) {
+ assert !ThreadUtils.runningOnUiThread();
+ 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);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698