You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by on...@apache.org on 2018/12/20 11:04:51 UTC

[camel] branch camel-2.22.x updated: CAMEL-13017 - handle root path on windows

This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch camel-2.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.22.x by this push:
     new 45775eb  CAMEL-13017 - handle root path on windows
45775eb is described below

commit 45775eb3af4256ef678193d1f4772e8096dcb5d4
Author: onders <on...@apache.org>
AuthorDate: Thu Dec 20 01:15:39 2018 +0300

    CAMEL-13017 - handle root path on windows
---
 .../apache/camel/component/file/remote/SftpOperations.java | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
index c60d0fa..2232c5e 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
@@ -593,8 +593,18 @@ public class SftpOperations implements RemoteFileOperations<SftpRemoteFile> {
         // that
         if (FileUtil.hasLeadingSeparator(path)) {
             // change to root path
-            doChangeDirectory(path.substring(0, 1));
-            path = path.substring(1);
+            if (!path.matches("^[a-zA-Z]:(//|\\\\).*$")) {
+                doChangeDirectory(path.substring(0, 1));
+                path = path.substring(1);
+            } else {
+                if(path.matches("^[a-zA-Z]:(//).*$")) {
+                    doChangeDirectory(path.substring(0, 3));
+                    path = path.substring(3);
+                } else if(path.matches("^[a-zA-Z]:(\\\\).*$")) {
+                    doChangeDirectory(path.substring(0, 4));
+                    path = path.substring(4);
+                }
+            }
         }
 
         // split into multiple dirs