Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52320822 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Gerrit Code Review
Browse files

Merge "Make FileUtils#createDir threadsafe"

parents 03c0059b 1d5dbcaa
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -1235,9 +1235,9 @@ public final class FileUtils {
    }

    /**
     * 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.
     * Creates a directory with name {@code name} under an existing directory {@code baseDir} if it
     * doesn't exist already. Returns a {@code File} object representing the directory if it exists
     * and {@code null} if not.
     *
     * @hide
     */
@@ -1247,13 +1247,23 @@ public final class FileUtils {
        return createDir(dir) ? dir : null;
    }

    /** @hide */
    /**
     * Ensure the given directory exists, creating it if needed. This method is threadsafe.
     *
     * @return false if the directory doesn't exist and couldn't be created
     *
     * @hide
     */
    public static boolean createDir(File dir) {
        if (dir.mkdir()) {
            return true;
        }

        if (dir.exists()) {
            return dir.isDirectory();
        }

        return dir.mkdir();
        return false;
    }

    /**