You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2006/07/21 16:42:05 UTC
svn commit: r424336 -
/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
Author: imario
Date: Fri Jul 21 07:42:05 2006
New Revision: 424336
URL: http://svn.apache.org/viewvc?rev=424336&view=rev
Log:
fix: npe on rename
fix: check if file exists as folder on createFile()
Modified:
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.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?rev=424336&r1=424335&r2=424336&view=diff
==============================================================================
--- 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 Fri Jul 21 07:42:05 2006
@@ -80,10 +80,10 @@
private FileName[] children;
private List objects;
- /**
- * FileServices instance.
- */
- private FileOperations operations;
+ /**
+ * FileServices instance.
+ */
+ private FileOperations operations;
protected AbstractFileObject(final FileName name,
final AbstractFileSystem fs)
@@ -561,7 +561,7 @@
if (files == null)
{
- return null;
+ return null;
}
else if (files.length == 0)
{
@@ -775,6 +775,11 @@
{
try
{
+ if (exists() && !FileType.FILE.equals(getType()))
+ {
+ throw new FileSystemException("vfs.provider/create-file.error", name);
+ }
+
if (!exists())
{
getOutputStream().close();
@@ -904,17 +909,17 @@
{
if (canRenameTo(destFile))
{
- if (!getParent().isWriteable())
- {
- throw new FileSystemException("vfs.provider/rename-parent-read-only.error", new FileName[] {getName(), getParent().getName()});
- }
+ if (!getParent().isWriteable())
+ {
+ throw new FileSystemException("vfs.provider/rename-parent-read-only.error", new FileName[]{getName(), getParent().getName()});
+ }
}
else
{
- if (!isWriteable())
- {
- throw new FileSystemException("vfs.provider/rename-read-only.error", getName());
- }
+ if (!isWriteable())
+ {
+ throw new FileSystemException("vfs.provider/rename-read-only.error", getName());
+ }
}
if (destFile.exists())
{
@@ -927,6 +932,7 @@
// issue rename on same filesystem
try
{
+ attach();
doRename(destFile);
((AbstractFileObject) destFile).handleCreate(getType());
@@ -1006,7 +1012,7 @@
*/
public FileContent getContent() throws FileSystemException
{
- synchronized(fs)
+ synchronized (fs)
{
attach();
if (content == null)
@@ -1364,7 +1370,7 @@
/**
* Notifies the file that its children have changed.
*
- * @deprecated use {@link #childrenChanged(FileName, FileType)}
+ * @deprecated use {@link #childrenChanged(FileName,FileType)}
*/
protected void childrenChanged() throws Exception
{
@@ -1574,20 +1580,20 @@
{
}
- // --- OPERATIONS ---
+ // --- OPERATIONS ---
- /**
- * @return FileOperations interface that provides access to the operations
- * API.
- * @throws FileSystemException
- */
- public FileOperations getFileOperations() throws FileSystemException
- {
- if (operations == null)
- {
- operations = new DefaultFileOperations(this);
- }
+ /**
+ * @return FileOperations interface that provides access to the operations
+ * API.
+ * @throws FileSystemException
+ */
+ public FileOperations getFileOperations() throws FileSystemException
+ {
+ if (operations == null)
+ {
+ operations = new DefaultFileOperations(this);
+ }
- return operations;
- }
+ return operations;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org