You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Updated) (JIRA)" <ji...@apache.org> on 2011/10/27 08:38:32 UTC

[jira] [Updated] (VFS-371) Add FileObject API deleteAllDescendents()

     [ https://issues.apache.org/jira/browse/VFS-371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory updated VFS-371:
--------------------------------

    Attachment: FileObject-deleteAllDescendents.diff

Patch with tests.
                
> Add FileObject API deleteAllDescendents()
> -----------------------------------------
>
>                 Key: VFS-371
>                 URL: https://issues.apache.org/jira/browse/VFS-371
>             Project: Commons VFS
>          Issue Type: New Feature
>         Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
> Maven home: C:\Java\apache-maven-3.0.3\bin\..
> Java version: 1.6.0_29, vendor: Sun Microsystems Inc.
> Java home: C:\Program Files\Java\jdk1.6.0_29\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary D. Gregory
>             Fix For: 2.1
>
>         Attachments: FileObject-deleteAllDescendents.diff
>
>
> I see a lot of call sites within VFS 2 and some in my work server that do:
> {code:java}
> fileObject.delete(Selectors.SELECT_ALL);
> {code}
> It therefore seems like a sensible refactoring.
> Add to {{FileObject}}:
> {code:java}
>     /**
>      * Deletes all descendents of this file.  
>      * Does nothing if this file does not exist.
>      * Shorthand for {@code delete(Selectors.Selectors.SELECT_ALL)}
>      * <p/>
>      * <p>This method is not transactional.  If it fails and throws an
>      * exception, this file will potentially only be partially deleted.
>      *
>      * @return the number of deleted objects
>      * @throws FileSystemException If this file or one of its descendents is read-only, or on error
>      *                             deleting this file or one of its descendents.
>      */
>     int deleteAllDescendents() throws FileSystemException;
> {code}
> And to {{AbstractFileObject}}:
> {code:java}
>     /**
>      * Deletes this file, and all children.
>      *
>      * @return the number of deleted files.
>      * @throws FileSystemException if an error occurs.
>      */
>     public int deleteAllDescendents() throws FileSystemException
>     {
>         return this.delete(Selectors.SELECT_ALL);
>     }
> {code}
> Thoughts?
> Attaching patch.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira