Improve handling of file paths in the windows DnD handler#980
Improve handling of file paths in the windows DnD handler#980Osspial merged 4 commits intorust-windowing:masterfrom streifmi:master
Conversation
|
Hi, and thanks for the PR! Sorry about the delay in looking at this. Couple points:
|
by replacing the call to mem::uninitialized with mem::zeroed and change file name retrieval to use buffers of exact length as reported by DragQueryFileW instead of relying on MAX_PATH.
|
Yes, exactly. If you want to test this, you have to first enable long path support on Windows 10 and then use a file manager that supports it (explorer.exe doesn't), like One Commander. If the application you drag the file from doesn't support long paths, it will either use the short path or if that's disabled generate no event at all. Note also that this alone won't help you much, if you then want to e.g. read that file. See this issue, for example. I did the change from Added the CHANGELOG entry and the comment, as requested. |
The Windows API generally expects structs to be zeroed rather than uninitialized, and this is mentioned in their API documentation. I remember having run into this before because I hadn't zeroed some struct that it expected to be zeroed. We should always use |
…wing#980) * Make FileDropHandler::iterate_filenames more robust by replacing the call to mem::uninitialized with mem::zeroed and change file name retrieval to use buffers of exact length as reported by DragQueryFileW instead of relying on MAX_PATH. * Change remaining calls of uninitialized to zeroed * Run rustfmt * Add CHANGELOG entry and comment
This changes
FileDropHandler::iterate_filenamesto use the exact length returned byDragQueryFileWinstead of relying on MAX_PATH.I've additionally replaced all calls to
mem::uninitializedwithmem::zeroed(on windows only).cargo fmthas been run on this branch