SpecialFolder.Trash(relativeToVolume)

  1. last year

    Michael D

    3 Jun 2019 Testers, Xojo Pro
    Edited last year

    Typeahead in 2019R1 shows

    SpecialFolder.Trash(relativeToVolume as folderItem=nil)

    and it compiles and works, e.g.

    SpecialFolder.Trash(Volume(0))

    But https://docs.xojo.com/SpecialFolder doesn't mention this parameter.

    Is this a documentation error, deprecation, or ???

  2. Greg O

    3 Jun 2019 Xojo Inc scout.galaxy.barn
    Edited last year

    Probably a documentarian error. I’ll check in the morning.

  3. 10 months ago

    Arnaud N

    26 Aug 2019 Testers, Xojo Pro A lost country in Switzerland.

    Please do. I'm looking at this to understand how it is implemented (are there caveats, e.g. if we pass the volume(0), would it refer to the user's trash folder, or the volume one?) and there's absolutely no documentation nor discussion I could find (today).

  4. Emile S

    26 Aug 2019 Europe (France, Strasbourg)
    MsgBox Str(SpecialFolder.Trash.Count)

    The above returns to me 3.

    I have the boot SSD and an external HD with 3 volumes.

    I “think” if you never trashed an item from a volume, there will not be any .Trash folder.

    SpecialFolder.Trash does not exists (no entry for it or is it been edited at asking time ?)

      Dim Boot_Trash_FI As FolderItem
      
      Boot_Trash_FI = SpecialFolder.Trash(Volume(0))

    The above returns a Reference to the Boot .Trash folder

    Is these enough implementation details ?

  5. 4 days ago

    Thomas R

    Jun 29 Europe, France, Besancon

    I did a sample code with a for next loop from 0 to FolderItem.LastDriveIndex and SpecialFolder.Trash(Volume(ThisIndex)) was always Nil .
    On my mother computer, SpecialFolder.Trash returns Nil (but I don't remember if it is El Capitan or Mojave).
    I'm on Mojave and SpecialFolder.Trash return "/Users/Tom/.Trash" ( Tom is my user name).

    A question : On Mojave, Trashes of external drives are in "/Volumes/MyExtDrive/.Trashes/501/" (or the index of the user). Is it the same under Catalina ?

  6. Sam R

    Jun 29 Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    I think you are supposed to find the volume that the file you are deleting resides on (use folderitem.parent). This avoids the OS from copying it across volumes to Trash it.

  7. Thomas R

    Jun 30 Europe, France, Besancon

    I'm not sure to understand when you write "file you are deleting". With Xojo, files are removed, not moved to the trash. I want to know the trash folder as I want to move my files to the trash instead of remove them.

  8. 3 days ago

    Sam R

    Jul 1 Testers, Xojo Pro, Third Party Store Hengchun, Pingtung, Taiwan

    @Thomas R I'm not sure to understand when you write "file you are deleting". With Xojo, files are removed, not moved to the trash. I want to know the trash folder as I want to move my files to the trash instead of remove them.

    Right, yeah, don't do it yourself as that's advice from Apple. Instead use API to tell the OS to move the file to the Trash.

    The code to do this is in the article I wrote for this issue of xDev http://www.xdevmag.com/browse/15.6/

    Or you can this code and whole lot more as part of the Ohanaware AppKit which is exclusive to the 2020 Omegabundle http://omegabundle.net

  9. Thomas R

    Jul 1 Europe, France, Besancon

    Ok thank you. I will have a look to your links.

  10. yesterday

    Arnaud N

    yesterday Testers, Xojo Pro A lost country in Switzerland.

    @Thomas R A question: On Mojave, Trashes of external drives are in "/Volumes/MyExtDrive/.Trashes/501/" (or the index of the user). Is it the same under Catalina?

    I can't answer for Catalina specifically, as I'm not using it often, but the path you describe has “always” existed on Mac OS. Most volumes have a “/.trashes” folder. This is obviously so the file doesn't have to be copied&deleted (i.e. moved) across volumes just to be moved to the trash.
    Those volumes that don't have such “.trashes” folders, like specific file systems or network volumes are the ones which trigger the Finder message (translated, might not be the exact same one): “Do you really want to delete “item name”? This item will be deleted permanently. This action is not undoable.”. That's because the Finder cannot create or find a suitable “.trashes” folder and can't use a trash (thus, it needs to delete the item immediately).

or Sign Up to reply!