Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5080625

File.moveTo{RecycleBin|Trash}() to support restore/undelete operation

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      Name: js151677 Date: 07/30/2004


      A DESCRIPTION OF THE REQUEST :
      PLEASE NOTE: this problem is not specific to Windows. This RFE is to add a method to the Java spec, so that a cross-platform solution is available to Java developers.

      java.io.File lacks a method to send a file to the operating system's Recycle Bin or Trash Can. Since the "Recycle Bin" paradigm has been adopted by several major operating systems (Windows, Mac OS X and Linux) it would be great to have a method in the File class to do this.

      This RFE does not suggest changing the delete() method in any way. In RFE bug 4641147 that type of enhancement was suggested and I agree that will "break crossplatform compatibility".

      Instead this RFE suggests that a new method be made, named something like moveToRecycleBin() or moveToTrash() in java.io.File. This method would use OS-specific calls to send the file to the Recycle Bin so it can be restored/undeleted by the user.

      JUSTIFICATION :
      Many modern operating systems support the "Recycle Bin" paradigm. In order for Java to succeed on the desktop, J2SE developers need to have desktop-specific methods available to us.

      In desktop software, there is a need sometimes for a simulated "file browser" in a view where file operations take place like rename/move/open/delete. It's quite common to have this in a IDE. In these file browsers, users expect the operations to act just like the native file browser available to them in the desktop environment. On Windows, for example, this is Windows Explorer.

      So in these file browsers when a user deletes a file, they expect it to show up in the Recycle Bin. This is typical for Windows applications like Visual Studio .NET 2003.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A call to moveToRecycleBin() or moveToTrash() would move the file from its current location to the operating system-specific Recycle Bin where it may be successfully recovered by the user.

      Like delete(), the method could return boolean indicating success or failure.

      On platforms where a move to Recycle Bin may not make sense (like on some Unix operating systems without a desktop environment or J2EE), then a simple call-through to delete() would suffice because that is the expected behaviour on a platform without a Recycle Bin.
      ACTUAL -
      Since there are operating system specific tasks that need to be done during the move to the Recycle Bin, this ability is currently not available to Java developers. It is not as simple as moving the file to the (hidden) Recycle Bin directory on Windows, for example.

      On Windows, the Win32 API shell function SHFileOperation() does a move to Recycle Bin. This would have to be called via JNI from Java.

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shfileoperation.asp
      (Incident Review ID: 290373)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jssunw Jitender S (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: