Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-371

Add FileObject API deleteAll()

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1
    • Labels:
      None
    • Environment:

      Description

      I see a lot of call sites within VFS 2 and some in my work server that do:

      fileObject.delete(Selectors.SELECT_ALL);
      

      It therefore seems like a sensible refactoring.

      Add to FileObject:

          /**
           * 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 deleteAll() throws FileSystemException;
      

      And to AbstractFileObject:

          /**
           * 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);
          }
      

      Thoughts?

      Attaching patch.

        Attachments

          Activity

            People

            • Assignee:
              ggregory Gary D. Gregory
              Reporter:
              ggregory Gary D. Gregory
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: