You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2016/11/11 19:52:48 UTC
[2/2] nifi git commit: NIFI-2818 This closes #1059. aligned read
method with read/write method
NIFI-2818 This closes #1059. aligned read method with read/write method
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/b9ef0fb8
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/b9ef0fb8
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/b9ef0fb8
Branch: refs/heads/master
Commit: b9ef0fb847cd2678a62964698f17a5afb37684b9
Parents: f32bdf7
Author: joewitt <jo...@apache.org>
Authored: Fri Nov 11 14:16:42 2016 -0500
Committer: joewitt <jo...@apache.org>
Committed: Fri Nov 11 14:52:13 2016 -0500
----------------------------------------------------------------------
.../java/org/apache/nifi/util/FileUtils.java | 21 ++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/b9ef0fb8/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/util/FileUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/util/FileUtils.java
index c66fad8..8ca63e5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/util/FileUtils.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/util/FileUtils.java
@@ -40,7 +40,7 @@ public class FileUtils {
}
public static void ensureDirectoryExistAndCanReadAndWrite(final File dir) throws IOException {
- if (dir.exists() && !dir.isDirectory() ) {
+ if (dir.exists() && !dir.isDirectory()) {
throw new IOException(dir.getAbsolutePath() + " is not a directory");
} else if (!dir.exists()) {
final boolean made = dir.mkdirs();
@@ -56,8 +56,13 @@ public class FileUtils {
public static void ensureDirectoryExistAndCanRead(final File dir) throws IOException {
if (dir.exists() && !dir.isDirectory()) {
throw new IOException(dir.getAbsolutePath() + " is not a directory");
+ } else if (!dir.exists()) {
+ final boolean made = dir.mkdirs();
+ if (!made) {
+ throw new IOException(dir.getAbsolutePath() + " could not be created");
+ }
}
- if (dir.exists() && !dir.canRead()) {
+ if (!dir.canRead()) {
throw new IOException(dir.getAbsolutePath() + " directory does not have read privilege");
}
}
@@ -118,8 +123,8 @@ public class FileUtils {
* @param directory to delete contents of
* @param filter if null then no filter is used
* @param logger to notify
- * @throws IOException if abstract pathname does not denote a directory,
- * or if an I/O error occurs
+ * @throws IOException if abstract pathname does not denote a directory, or
+ * if an I/O error occurs
*/
public static void deleteFilesInDirectory(final File directory, final FilenameFilter filter, final Logger logger) throws IOException {
FileUtils.deleteFilesInDirectory(directory, filter, logger, false);
@@ -134,8 +139,8 @@ public class FileUtils {
* @param filter if null then no filter is used
* @param logger to notify
* @param recurse true if should recurse
- * @throws IOException if abstract pathname does not denote a directory,
- * or if an I/O error occurs
+ * @throws IOException if abstract pathname does not denote a directory, or
+ * if an I/O error occurs
*/
public static void deleteFilesInDirectory(final File directory, final FilenameFilter filter, final Logger logger, final boolean recurse) throws IOException {
FileUtils.deleteFilesInDirectory(directory, filter, logger, recurse, false);
@@ -152,8 +157,8 @@ public class FileUtils {
* @param recurse will look for contents of sub directories.
* @param deleteEmptyDirectories default is false; if true will delete
* directories found that are empty
- * @throws IOException if abstract pathname does not denote a directory,
- * or if an I/O error occurs
+ * @throws IOException if abstract pathname does not denote a directory, or
+ * if an I/O error occurs
*/
public static void deleteFilesInDirectory(final File directory, final FilenameFilter filter, final Logger logger, final boolean recurse, final boolean deleteEmptyDirectories) throws IOException {
// ensure the specified directory is actually a directory and that it exists