Recover files from the Trash

Hi, ALL,

Is there an API in Cocoa Objective-C that will allow restore file(s) from Trash? And possibly get the list of files inside the Trash...

Thank you.

Replies

Is there an API in Cocoa Objective-C that will allow restore file(s) from Trash?

No.

Back in the day there was a supported way to determine the original location of a trashed item (see putAwayFolderID in <Files.h>) but that is no longer in use.

And possibly get the list of files inside the Trash...

Not really.

Keep in mind that the Trash is a concept synthesised by the Finder; it doesn’t actually exist in reality. So, while it’s possible to locate the Trash directory for your user on a specific volume [1], there’s no good way to generate a coherent view of the trash from that info.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Using FileManager.url(for:in:appropriateFor:create:) with the .trashDirectory selector.

  • @eskimo,

    Is it possible to restore the files from Trash? Maybe not with a single API call, but a little function...

    Thank you.

Add a Comment

Is it possible to restore the files from Trash?

What about my previous answer was unclear?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • @eskimo, Interesting. So there is a function to send file(s) to Trash, either synchronously or asynchronously, but there is no API to recover them from Trash.

    OSX is definitely a weird OS. ;-)

    Thank you.

Add a Comment