Author: davsclaus
Date: Sat Mar 16 07:33:59 2013
New Revision: 1457220
URL: http://svn.apache.org/r1457220
Log:
CAMEL-6056: Improved logic when changing file name to better handle dir slash
in windows or unix style
Modified:
camel/branches/camel-2.10.x/ (props changed)
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1456989
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=1457220&r1=1457219&r2=1457220&view=diff
==============================================================================
---
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
(original)
+++
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Sat Mar 16 07:33:59 2013
@@ -171,19 +171,22 @@ public class GenericFile<T> implements W
// Make sure the newName is normalized.
String newFileName = normalizePath(newName);
+ String newEndpointPath = normalizePath(endpointPath);
- LOG.trace("Normalized endpointPath: {}", endpointPath);
+ LOG.trace("Normalized endpointPath: {}", newEndpointPath);
LOG.trace("Normalized newFileName: ()", newFileName);
File file = new File(newFileName);
if (!absolute) {
// for relative then we should avoid having the endpoint path
duplicated so clip it
- if (ObjectHelper.isNotEmpty(endpointPath) &&
newFileName.startsWith(endpointPath)) {
+ if (ObjectHelper.isNotEmpty(newEndpointPath) &&
newFileName.startsWith(newEndpointPath)) {
// clip starting endpoint in case it was added
- if (endpointPath.endsWith("" + getFileSeparator())) {
- newFileName = ObjectHelper.after(newFileName,
endpointPath);
+ // use File.separatorChar as the normalizePath uses this as
path separator so we should use the same
+ // in this logic here
+ if (newEndpointPath.endsWith("" + File.separatorChar)) {
+ newFileName = ObjectHelper.after(newFileName,
newEndpointPath);
} else {
- newFileName = ObjectHelper.after(newFileName, endpointPath
+ getFileSeparator());
+ newFileName = ObjectHelper.after(newFileName,
newEndpointPath + File.separatorChar);
}
// reconstruct file with clipped name