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