diff options
| author | Jeff Sharkey <jsharkey@google.com> | 2015-07-22 19:40:44 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-22 19:40:44 +0000 |
| commit | f6e9a3ede53ae487838c19714ad62f25a4a6ca4c (patch) | |
| tree | ddc88092c0d07f9d933d097a34e8312655b930e1 /core/java/android/os/FileUtils.java | |
| parent | 4fc1b707442451f4a826929fc7e72967d443c73f (diff) | |
| parent | 85ced632680642fce680d141ddd10299ff849233 (diff) | |
| download | frameworks_base-f6e9a3ede53ae487838c19714ad62f25a4a6ca4c.zip frameworks_base-f6e9a3ede53ae487838c19714ad62f25a4a6ca4c.tar.gz frameworks_base-f6e9a3ede53ae487838c19714ad62f25a4a6ca4c.tar.bz2 | |
Merge "More info to support CTS, fix reconcile bug." into mnc-dev
Diffstat (limited to 'core/java/android/os/FileUtils.java')
| -rw-r--r-- | core/java/android/os/FileUtils.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 864225a..af4c2bc 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -16,6 +16,7 @@ package android.os; +import android.annotation.NonNull; import android.provider.DocumentsContract.Document; import android.system.ErrnoException; import android.system.Os; @@ -69,6 +70,8 @@ public class FileUtils { /** Regular expression for safe filenames: no spaces or metacharacters */ private static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+"); + private static final File[] EMPTY = new File[0]; + /** * Set owner and mode of of given {@link File}. * @@ -634,4 +637,13 @@ public class FileUtils { return new File(parent, name + "." + ext); } } + + public static @NonNull File[] listFilesOrEmpty(File dir) { + File[] res = dir.listFiles(); + if (res != null) { + return res; + } else { + return EMPTY; + } + } } |
