Hi,

Hmmm - we found that this doesn't work when camel is runing on unix and the
ftp-server is windows:

If existing is aa/bb/cc\test.txt and OS (where camel runs) is windows then  
normalizePath(existing) = aa\bb\cc\test.txt (i.e. fil separators are
normalized)
and stripPath(normalizePath(existing)) = test.txt (it takes substring after
last position of / or File.separator=\)

If existing is aa/bb/cc\test.txt and OS (where camel runs) is NOT windows
then 
normalizePath(existing) = aa/bb/cc\test.txt (i.e. unchanged)
og stripPath(normalizePath(existing)) = Test\test.txt (it takes substring
after last position of / or File.separator=\)

Instead we are now using the following method added to the FtpOperations - 

    // Will return substring from last occurence of either / or \ - works as
long as / or \ are not part of the file name
    public static String onlyFileName(String name){
        char unixSep = '/';
        char winSep = '\\';
        if (name == null) {
            return null;
        }
        int unixPos = name.lastIndexOf(unixSep);
        int winPos = name.lastIndexOf(winSep);
        if (unixPos > winPos) {
            return name.substring(unixPos + 1);
        }
        if (winPos > unixPos) {
            return name.substring(winPos + 1);
        }
        return name;
    }

I have updated the jira-issue accordingly.

Regards
Mikael
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Problem-renaming-existing-file-in-FTP-tp3307670p3363358.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to