Author: davsclaus
Date: Fri Mar 15 15:39:34 2013
New Revision: 1456989
URL: http://svn.apache.org/r1456989
Log:
CAMEL-6056: Improved logic when changing file name to better handle dir slash
in windows or unix style
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=1456989&r1=1456988&r2=1456989&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Fri Mar 15 15:39:34 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