diff options
| author | Narayan Kamath <narayan@google.com> | 2017-01-06 09:13:59 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-01-06 09:14:03 +0000 |
| commit | 3aea7330591e90a44e2bceb76decfe879bcdf8e5 (patch) | |
| tree | a965c72b8cbcf8e7db1279dc92f10d0d38beceaf /core/java/android | |
| parent | 9f19a7f3b98b6385177a106dd5ba28b8c292ce82 (diff) | |
| parent | 5c50e8630164d7d9a1a097f70d2f8bcbf1bd854f (diff) | |
Merge "PackageManagerService: Implement packageParser cache in ParallelPackageParser."
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/os/FileUtils.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 760df45d2b69..73c9462403f2 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -762,4 +762,19 @@ public class FileUtils { public static @Nullable File newFileOrNull(@Nullable String path) { return (path != null) ? new File(path) : null; } + + /** + * Creates a directory with name {@code name} under an existing directory {@code baseDir}. + * Returns a {@code File} object representing the directory on success, {@code null} on + * failure. + */ + public static @Nullable File createDir(File baseDir, String name) { + final File dir = new File(baseDir, name); + + if (dir.exists()) { + return dir.isDirectory() ? dir : null; + } + + return dir.mkdir() ? dir : null; + } } |
