Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃毀 WIP: macOS trash "put back" feature [ctypes] #25

Closed
wants to merge 1 commit into from
Closed

馃毀 WIP: macOS trash "put back" feature [ctypes] #25

wants to merge 1 commit into from

Conversation

acheronfail
Copy link

@acheronfail acheronfail commented Apr 12, 2018

This is a WIP!


This is my initial attempt at using ctypes, just putting it up online so we have a record of it, and also to help catch if I've done anything wrong.

I was hopeful about the progress I was making, until I came across some hurdles that have blocked this approach. At the moment running it causes a segmentation fault (I believe because of the incorrectly initialised AEDesc). We need:

  • Need to find a way to initialise:
    • AEDesc
    • AEDataStorage
  • Need to confirm how the following values should be defined:
    • typeKernelProcessID
    • typeWildCard
    • keyDirectObject
    • pid_t

If this turns out to be too arch-dependent, or too much of a hack, I'll open a different PR using some compiled Objective-C.

Fixes #9.

/cc @BoboTiG @hsoft

@acheronfail
Copy link
Author

In the meantime, I'll investigate other methods of asking Finder to trash the file - maybe there's another way where we don't have to use AEDesc structs and so forth.

@acheronfail acheronfail changed the title 馃毀 WIP: macOS trash "put back" feature 馃毀 WIP: macOS trash "put back" feature [ctypes] Apr 12, 2018
@ghost
Copy link

ghost commented Apr 12, 2018

Looks like you're well started. It will be a nice feature to have!

I don't have a Mac to test on anymore though. It would be great if someone could volunteer to test @acheronfail's code.

@acheronfail
Copy link
Author

I've just found this: https://github.com/sindresorhus/macos-trash which may actually be a lot easier than the way we're doing it now, I'll give it a crack and update here.

@ghost
Copy link

ghost commented Apr 12, 2018

See? I told you there was a better way :) If it works, it will indeed be much easier and faster.

@acheronfail
Copy link
Author

acheronfail commented Apr 12, 2018

Ahh, I missed this issue on their tracker: sindresorhus/macos-trash#4 馃憥

@ghost
Copy link

ghost commented Apr 12, 2018

Whoa, good job Apple... At least I know that I wasn't dreaming when I thought I remembered send2trash working with "Put Back" in the good old days.

@acheronfail
Copy link
Author

acheronfail commented Apr 12, 2018

I've even tried things like https://developer.apple.com/documentation/appkit/nsworkspace/1530465-recycleurls?language=objc and I'm having no such luck, even running straight Objective-C code.

Looks like this is actually an Apple bug, and running it using event descriptors (like https://github.com/ali-rantakari/trash/blob/master/trash.m#L265-L340) might be the only legitimate to get this to work. :sigh: thanks for that Apple!

@ghost ghost closed this May 27, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

after deleted by send2trash there is no "put back" or "restore" in the right click menu in trash on OSX
1 participant