# HG changeset patch # User postspectacular # Date 1327487782 0 # Node ID 5acdef0df9f6225c20b10907fd05fd1fc123d219 # Parent 203b4bda6b2aca5b4d4f070ece9cbcd6f6849ee0 changing behavior for FileUtils.createDirectories() to literally create any directories for the given path, re-creating existing behavior as createDirectoriesForFile() (creating parent directories for a given file) diff -r 203b4bda6b2aca5b4d4f070ece9cbcd6f6849ee0 -r 5acdef0df9f6225c20b10907fd05fd1fc123d219 src.core/toxi/util/FileUtils.java --- a/src.core/toxi/util/FileUtils.java Wed Jan 25 10:31:32 2012 +0000 +++ b/src.core/toxi/util/FileUtils.java Wed Jan 25 10:36:22 2012 +0000 @@ -63,11 +63,33 @@ /** * Attempts to create the full path of directories as specified by the given + * target path. The path is assumed to be a directory, NOT a file in a + * directory. For the latter, use {@link #createDirectoriesForFile(File)}. + * + * @param path + * @return true, if the operation succeeded + */ + static public boolean createDirectories(File path) { + try { + if (!path.exists()) { + path.mkdirs(); + } + return true; + } catch (SecurityException se) { + System.err.println("No permissions to create " + + path.getAbsolutePath()); + } + return false; + } + + /** + * Attempts to create the full path of directories as specified by the given * target file. * * @param file + * @return true, if the operation succeeded */ - static public void createDirectories(File file) { + static public boolean createDirectoriesForFile(File file) { try { String parentName = file.getParent(); if (parentName != null) { @@ -76,10 +98,12 @@ parent.mkdirs(); } } + return true; } catch (SecurityException se) { System.err.println("No permissions to create " + file.getAbsolutePath()); } + return false; } /**