You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/05/23 09:49:00 UTC

[10/11] camel git commit: CAMEL-11298: Added additional logic to handle absolute and relative paths when using chmodDirectory.

CAMEL-11298: Added additional logic to handle absolute and relative paths when using chmodDirectory.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b54324a9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b54324a9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b54324a9

Branch: refs/heads/camel-2.18.x
Commit: b54324a9206bfe0c3a456eaa36d4bad175c6ace9
Parents: 4634558
Author: Damyan Damyanov <da...@scalefocus.com>
Authored: Mon May 22 17:43:49 2017 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue May 23 11:48:21 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/component/file/FileOperations.java | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b54324a9/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
index 8a523d7..c660295 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
@@ -81,7 +81,7 @@ public class FileOperations implements GenericFileOperations<File> {
         return file.exists();
     }
 
-    protected boolean buildDirectory(File dir, Set<PosixFilePermission> permissions) {
+    protected boolean buildDirectory(File dir, Set<PosixFilePermission> permissions, boolean absolute) {
         if (dir.exists()) {
             return true;
         }
@@ -93,7 +93,15 @@ public class FileOperations implements GenericFileOperations<File> {
         // create directory one part of a time and set permissions
         try {
             String[] parts = dir.getPath().split("\\" + File.separatorChar);
-            File base = new File("");
+
+            File base;
+            // reusing absolute flag to handle relative and absolute paths
+            if (absolute) {
+                base = new File("");
+            } else {
+                base = new File(".");
+            }
+
             for (String part : parts) {
                 File subDir = new File(base, part);
                 if (!subDir.exists()) {
@@ -121,7 +129,7 @@ public class FileOperations implements GenericFileOperations<File> {
         // always create endpoint defined directory
         if (endpoint.isAutoCreate() && !endpoint.getFile().exists()) {
             LOG.trace("Building starting directory: {}", endpoint.getFile());
-            buildDirectory(endpoint.getFile(), endpoint.getDirectoryPermissions());
+            buildDirectory(endpoint.getFile(), endpoint.getDirectoryPermissions(), absolute);
         }
 
         if (ObjectHelper.isEmpty(directory)) {
@@ -158,7 +166,7 @@ public class FileOperations implements GenericFileOperations<File> {
                 return true;
             } else {
                 LOG.trace("Building directory: {}", path);
-                return buildDirectory(path, endpoint.getDirectoryPermissions());
+                return buildDirectory(path, endpoint.getDirectoryPermissions(), absolute);
             }
         }
     }