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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to differentiate between files that have been either cut or copied #27

Open
Jamzy01 opened this issue Jul 3, 2023 · 5 comments
Open

Comments

@Jamzy01
Copy link

Jamzy01 commented Jul 3, 2023

When reading and writing to the clipboard using the FileList format, how can I specify and detect whether a file/folder has been cut or copied.

@DoumanAsh
Copy link
Owner

I don't think WinAPI distinguish between these cases or at least it is not exposed in public API as far as I know

@Jamzy01
Copy link
Author

Jamzy01 commented Jul 3, 2023

I am using this for a file explorer app and want clipboard operations between my app and the windows file explorer to function properly together. Clearly the windows file explorer has a way to distinguish between cut and copied files, although I am not sure whether this is tracked by some form of internal state or by the clipboard data itself. I would assume that this data would be included in the clipboard data itself, although I am no expert on the windows api and am not entirely sure.

@DoumanAsh
Copy link
Owner

Well, in case of windows explorer when you perform Cut/Copy, it is performed via explorer always (even when you use keyboard shortcut, it is handled by explorer) so I would assume it remembers every file copied/cut
Unfortunately I cannot give you 100% answer as it is possible Microsoft uses some undocumented API for this purpose.

If you can find way to access this status, I do not mind to expose it in this crate, but unfortunately I myself is not aware of way to do so.

@Jamzy01
Copy link
Author

Jamzy01 commented Jul 3, 2023

As you can see here, when cutting a file and then inspecting the clipboard using the InsideClipboard app (https://www.nirsoft.net/utils/inside_clipboard.html), it shows a preferred drop effect of 02 00 00 00.

image

And then when I copy that exact same file, and then inspecting the clipboard, it shows a preferred drop effect of 05 00 00 00

image

I found a webpage that I assume documents this functionality: https://learn.microsoft.com/en-us/windows/win32/com/dropeffect-constants, although considering this was based on a google search, once again I am not certain.

@DoumanAsh
Copy link
Owner

Thanks, that's good hint

I guess they store this information as sort of hint.
But when we query using DragQueryFileW it is not really exposed, I only get file paths.
I will try to investigate if there is API to enumerate all files with raw struct.

It is unfortunate that this tool is closed sourced
Not sure if there is any public API to enumerate file structure like this tool does, so I probably need to check winapi headers first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants