private boolean mkdirsInternal(File file) throws IOException { if (file.isDirectory()) { return true; } else if (file.exists() && !file.isDirectory()) { // Important: The 'exists()' check above must come before the 'isDirectory()' check to // be safe when multiple parallel instances try to create the directory // exists and is not a directory -> is a regular file throw new FileAlreadyExistsException(file.getAbsolutePath()); } else { File parent = file.getParentFile(); return (parent == null || mkdirsInternal(parent)) && (file.mkdir() || file.isDirectory()); } }
/** * Recursively creates the directory specified by the provided path. * * @return <code>true</code>if the directories either already existed or have been created successfully, * <code>false</code> otherwise * @throws IOException * thrown if an error occurred while creating the directory/directories */ @Override public boolean mkdirs(final Path f) throws IOException { checkNotNull(f, "path is null"); return mkdirsInternal(pathToFile(f)); }
private boolean mkdirsInternal(File file) throws IOException { if (file.isDirectory()) { return true; } else if (file.exists() && !file.isDirectory()) { // Important: The 'exists()' check above must come before the 'isDirectory()' check to // be safe when multiple parallel instances try to create the directory // exists and is not a directory -> is a regular file throw new FileAlreadyExistsException(file.getAbsolutePath()); } else { File parent = file.getParentFile(); return (parent == null || mkdirsInternal(parent)) && (file.mkdir() || file.isDirectory()); } }
private boolean mkdirsInternal(File file) throws IOException { if (file.isDirectory()) { return true; } else if (file.exists() && !file.isDirectory()) { // Important: The 'exists()' check above must come before the 'isDirectory()' check to // be safe when multiple parallel instances try to create the directory // exists and is not a directory -> is a regular file throw new FileAlreadyExistsException(file.getAbsolutePath()); } else { File parent = file.getParentFile(); return (parent == null || mkdirsInternal(parent)) && (file.mkdir() || file.isDirectory()); } }
/** * Recursively creates the directory specified by the provided path. * * @return <code>true</code>if the directories either already existed or have been created successfully, * <code>false</code> otherwise * @throws IOException * thrown if an error occurred while creating the directory/directories */ @Override public boolean mkdirs(final Path f) throws IOException { checkNotNull(f, "path is null"); return mkdirsInternal(pathToFile(f)); }
/** * Recursively creates the directory specified by the provided path. * * @return <code>true</code>if the directories either already existed or have been created successfully, * <code>false</code> otherwise * @throws IOException * thrown if an error occurred while creating the directory/directories */ @Override public boolean mkdirs(final Path f) throws IOException { checkNotNull(f, "path is null"); return mkdirsInternal(pathToFile(f)); }