Author: imario
Date: Mon Oct 2 11:49:41 2006
New Revision: 452172
URL: http://svn.apache.org/viewvc?view=rev&rev=452172
Log:
VFS-73: fix for handling move operations where only the case of the file
changes (ie on windows filesytems)
Modified:
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
Modified:
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java?view=diff&rev=452172&r1=452171&r2=452172
==============================================================================
---
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
(original)
+++
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
Mon Oct 2 11:49:41 2006
@@ -921,7 +921,8 @@
throw new
FileSystemException("vfs.provider/rename-read-only.error", getName());
}
}
- if (destFile.exists())
+
+ if (destFile.exists() && !isSameFile(destFile))
{
destFile.delete(Selectors.SELECT_ALL);
// throw new
FileSystemException("vfs.provider/rename-dest-exists.error",
destFile.getName());
@@ -970,6 +971,27 @@
deleteSelf();
}
+ }
+
+ /**
+ * Checks if this fileObject is the same file as <code>destFile</code>
just with a different
+ * name.<br />
+ * E.g. for case insensitive filesystems like windows.
+ */
+ protected boolean isSameFile(FileObject destFile) throws
FileSystemException
+ {
+ attach();
+ return doIsSameFile(destFile);
+ }
+
+ /**
+ * Checks if this fileObject is the same file as <code>destFile</code>
just with a different
+ * name.<br />
+ * E.g. for case insensitive filesystems like windows.
+ */
+ protected boolean doIsSameFile(FileObject destFile) throws
FileSystemException
+ {
+ return false;
}
/**
Modified:
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java?view=diff&rev=452172&r1=452171&r2=452172
==============================================================================
---
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
(original)
+++
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
Mon Oct 2 11:49:41 2006
@@ -23,12 +23,14 @@
import org.apache.commons.vfs.provider.AbstractFileObject;
import org.apache.commons.vfs.provider.UriParser;
import org.apache.commons.vfs.util.RandomAccessMode;
+import org.apache.commons.vfs.util.FileObjectUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.IOException;
/**
* A file object implementation which uses direct file access.
@@ -223,5 +225,29 @@
protected RandomAccessContent doGetRandomAccessContent(final
RandomAccessMode mode) throws Exception
{
return new LocalFileRandomAccessContent(file, mode);
+ }
+
+ protected boolean doIsSameFile(FileObject destFile) throws
FileSystemException
+ {
+ if (!FileObjectUtils.isInstanceOf(destFile, LocalFile.class))
+ {
+ return false;
+ }
+
+ LocalFile destLocalFile = (LocalFile)
FileObjectUtils.getAbstractFileObject(destFile);
+ if (!exists() || !destLocalFile.exists())
+ {
+ return false;
+ }
+
+ try
+ {
+ return
file.getCanonicalPath().equals(destLocalFile.file.getCanonicalPath());
+ }
+ catch (IOException e)
+ {
+ throw new FileSystemException(e);
+ }
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]