No trash

When opening a file from my app there is a check if the folderitem is in the trash. Just got a report from a customer that there is no trash found:

dim theTrashFolder as FolderItem = theFolderitem.TrashFolder if theTrashFolder = Nil then globals.theErrorLog.LogItem "trash is nil" theTrashFolder = SpecialFolder.Trash end if if theTrashFolder = Nil then globals.theErrorLog.DialogErrorProceed(kErrorNoTrash) Return False end if

Any idea what might be wrong with this code? System of the customer is High Sierra.

I’m creating the trash folder if there isn’t one with the appropriate CreateTrashFolderMBS function.

The problem is on the system of the user. He seems to have lost his trash.

Each Hard Disk have its own Trash. The contents of each Trash is displayed just ike if it is in the Boot Hard Disk.

Trash is a user environment thing, not a disk one. It’s a folder under home’s user (or something similar under windows)

As my code shows the user has lost all his trashes. I made him a small test app with CreateTrashFolderMBS and different domains (user and appropriate disk). And still no trash.

Read the Apple documentation and you will learn some things

If this was the case, what would you expect to happen when the user connects an external HFS+ disk to the Mac (or already has several disks/volumes mounted), select a random file/folder in that volume and put it to the trash (a fairly regular operation)?
Given your statement, the selected item would have to be moved to /Users/username/.Trash (the user’s trash folder) from the source volume. This implies the data must be transferred (read from source volume then written to the target volume). Try it yourself: temporarily put one big file (or one big folder) on another volume than the startup volume to the trash from the Finder (or using the Terminal or other files browsers): this is done immediately, no read/write done (except reassigning the parent folder, which is immediate). Logically, there have to be trashes on each volume. This is indeed the case. Mount an arbitrary volume to your mac (works, at least, with HFS+ and Fat32 volumes) and look at invisible items it contain ((1) show invisibles files in the Finder or (2) use the terminal ((a): cd /volumes/yourvolume, (b): ls -a) or (3) use Path Finder or (4) iterate in the volume’s root folder from within Xojo): you’ll see there is a .trashes folder there, for that purpose.

I don’t say the trash folder of the logged-in user isn’t stored in an environnement variable, but it’s wrong to assume it’s only that.

  1. Empty your Trash

  2. Mount a removable disk

  3. Move a file on the removable disk to the Trash. Notice that the Trash is non-empty.

  4. Eject the removable disk. Notice that the Trash is now empty.

  5. Repeat step (2). Notice that the Trash is non-empty again.

Also (if I am not mistaken) and SSD doesn’t have a trash folder

My external SSD certainly has a .Trashes directory. Forcing my way into it, I see there is a directory with my uid.