SpecialFolder.Trash(relativeToVolume)

Typeahead in 2019R1 shows

SpecialFolder.Trash(relativeToVolume as folderItem=nil)

and it compiles and works, e.g.

SpecialFolder.Trash(Volume(0))

But SpecialFolder — Xojo documentation doesn’t mention this parameter.

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

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

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).

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 ?)

[code]
Dim Boot_Trash_FI As FolderItem

Boot_Trash_FI = SpecialFolder.Trash(Volume(0))[/code]

The above returns a Reference to the Boot .Trash folder

Is these enough implementation details ?

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 ?

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.

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 Contents of Issue 15.6 (November/December 2017)

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

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

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).