Ignore:
Timestamp:
2016-01-27T02:01:55+01:00 (8 years ago)
Author:
Don-vip
Message:

fix findbugs issue RV_RETURN_VALUE_IGNORED_BAD_PRACTICE for java.io.File.mkdirs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r9477 r9645  
    460460     * Deletes a file and log a default warning if the deletion fails.
    461461     * @param file file to delete
    462      * and must contain a single parameter <code>{0}</code> for the file path
    463462     * @return {@code true} if and only if the file is successfully deleted; {@code false} otherwise
    464463     * @since 9296
     
    480479        if (!result) {
    481480            Main.warn(tr(warnMsg, file.getPath()));
     481        }
     482        return result;
     483    }
     484
     485    /**
     486     * Creates a directory and log a default warning if the creation fails.
     487     * @param dir directory to create
     488     * @return {@code true} if and only if the directory is successfully created; {@code false} otherwise
     489     * @since 9645
     490     */
     491    public static boolean mkDirs(File dir) {
     492        return mkDirs(dir, marktr("Unable to create directory {0}"));
     493    }
     494
     495    /**
     496     * Creates a directory and log a configurable warning if the creation fails.
     497     * @param dir directory to create
     498     * @param warnMsg warning message. It will be translated with {@code tr()}
     499     * and must contain a single parameter <code>{0}</code> for the directory path
     500     * @return {@code true} if and only if the directory is successfully created; {@code false} otherwise
     501     * @since 9645
     502     */
     503    public static boolean mkDirs(File dir, String warnMsg) {
     504        boolean result = dir.mkdirs();
     505        if (!result) {
     506            Main.warn(tr(warnMsg, dir.getPath()));
    482507        }
    483508        return result;
Note: See TracChangeset for help on using the changeset viewer.