You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/03/11 11:45:56 UTC
svn commit: r752421 - in
/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file:
FileOperations.java GenericFile.java
Author: ningjiang
Date: Wed Mar 11 10:45:56 2009
New Revision: 752421
URL: http://svn.apache.org/viewvc?rev=752421&view=rev
Log:
Fixed the unitest error of MoveFilesToDirectoryTest
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
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/FileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java?rev=752421&r1=752420&r2=752421&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java Wed Mar 11 10:45:56 2009
@@ -60,6 +60,7 @@
public boolean renameFile(String from, String to) throws GenericFileOperationFailedException {
File file = new File(from);
File target = new File(to);
+ //System.out.println("rename the file from " + from + " to " + to);
return file.renameTo(target);
}
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=752421&r1=752420&r2=752421&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 Wed Mar 11 10:45:56 2009
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.Serializable;
+import org.apache.camel.util.FileUtil;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -93,17 +94,20 @@
public void changeFileName(String newName) {
if (LOG.isTraceEnabled()) {
LOG.trace("Changing name to: " + newName);
- }
-
- File file = new File(newName);
+ }
+ // Make sure the newName is normalized.
+ String newFileName = FileUtil.normalizePath(newName);
+ 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) && newName.startsWith(endpointPath)) {
+ System.out.println("endpointPath " + endpointPath);
+ System.out.println("newName " + newFileName);
+ if (ObjectHelper.isNotEmpty(endpointPath) && newFileName.startsWith(endpointPath)) {
// clip starting endpoint in case it was added
- newName = ObjectHelper.after(newName, endpointPath + getFileSeparator());
+ newFileName = ObjectHelper.after(newFileName, endpointPath + getFileSeparator());
// reconstruct file with clipped name
- file = new File(newName);
+ file = new File(newFileName);
}
}
@@ -119,9 +123,9 @@
}
// absolute path
- if (isAbsolute(newName)) {
+ if (isAbsolute(newFileName)) {
setAbsolute(true);
- setAbsoluteFilePath(newName);
+ setAbsoluteFilePath(newFileName);
} else {
setAbsolute(false);
// construct a pseudo absolute filename that the file operations uses even for relative only