The last time I checked, the "Put Back" function was completely specific to the Finder. That is, moving the file to the trash programmatically prevents even Finder from returning it. Only items trimmed by the Finder can be returned by the Finder. (Even dragging an item from a folder on the dock to the trash does not allow it to be returned, because the Dock cut it off, not Finder.)
Even for an item that the Finder can return, there is no documented way to perform the "Put Back" operation programmatically.
However, for your own application, you can, of course, cancel the operation without saving a separate copy of the file (until the user empties the garbage). -[NSWorkspace recycleURLs:completionHandler:]
will provide you with URLs for items in the trash. Store bookmark data for these URLs and the source containing folder, as well as the original name. To cancel, enable the bookmark data for the item in the basket and the original containing folder and transfer the first to the last with the original name, except that do not clog the new file that was created in its place. If the move cannot be completed without merging, try adding the suffix number to the file name. Continue to enlarge until you find an unused name.
If the resolution of these bookmarks fails, the operation cannot be completed, and you must report this to the user.
source share