camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [02/11] camel git commit: CAMEL-11298: Added additional logic to handle absolute and relative paths when using chmodDirectory.
Date Tue, 23 May 2017 09:48:52 GMT
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/b35e8feb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b35e8feb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b35e8feb

Branch: refs/heads/master
Commit: b35e8feb846ca4d9ee2b0d75dedafffb3bbab2e7
Parents: 3c8ae8d
Author: Damyan Damyanov <damyan.damyanov@scalefocus.com>
Authored: Mon May 22 17:43:49 2017 +0300
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue May 23 11:14:47 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/b35e8feb/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);
             }
         }
     }


Mime
View raw message