godot icon indicating copy to clipboard operation
godot copied to clipboard

Windows: Fix dragging and dropping files from compressed files into editor

Open Garetonchick opened this issue 1 year ago • 2 comments

Fixes #97128.

Use case described by @Maran23 in https://github.com/godotengine/godot/issues/97128#issuecomment-2357090873 still doesn't work. I can look into it later.

Garetonchick avatar Sep 20 '24 21:09 Garetonchick

Good job, and congratulations on your first commit! I tested this and it does appear to work in regards to the issue I raised with 7zip. I'll approve this for now, but would you mind squashing the commits from this PR into a single commit? We generally prefer that convention when merging.

Thank you! I have squashed the commits.

Garetonchick avatar Oct 10 '24 10:10 Garetonchick

Seems to be working as expected.

Use case described by @Maran23 in #97128 (comment) still doesn't work. I can look into it later.

This likely requires handling CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR in addition to CF_HDROP.

Added handling of CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS as you have suggested. Now drag-and-drop from inside the .zip file from Windows Explorer also works. Also I tested the same case with Total Commander and it works as well.

However, this time I had to do a bit of filesystem manipulations and couldn't find some functinality in Godot's source code. These are: joining filepaths with correct OS separator, creating temporary directory with random name, creating all subdirectories for a path and recursively removing directory with it's contents. For now I have written quick & dirty implementations of these, which are not general purpose, but happen to work here. So I would appreciate it if someone pointed me to the relevant existing functionality. Or if it doesn't exist, it probably should be added (maybe in a separate PR?) for general use.

Garetonchick avatar Oct 16 '24 11:10 Garetonchick

These are: joining filepaths with correct OS separator, creating temporary directory with random name, creating all subdirectories for a path and recursively removing directory with it's contents.

There's DirAccess::erase_contents_recursive, DirAccess::make_dir_recursive and String::path_join (like all other public Godot IO functions, these use / separator, usually conversion is done internally right before passing path to the system API and never exposed to the user, see fix_path in OS_Windows).

https://github.com/godotengine/godot/blob/b3bcb2dc14691f7729984128dca26a844f662fa1/platform/windows/os_windows.cpp#L93-L108

bruvzg avatar Oct 22 '24 04:10 bruvzg

Do we want to wait and try to solve that edge-case, or is this ready to merge now in your eyes?

Repiteo avatar Nov 05 '24 04:11 Repiteo

Do we want to wait and try to solve that edge-case, or is this ready to merge now in your eyes?

I think it's okay to merge. This edge case doesn't cause issues on my system (Windows 10), so I can't debug @Calinou's problem on Windows 11. I believe fixing it should be in a separate PR done by someone else.

Garetonchick avatar Nov 05 '24 10:11 Garetonchick

Thanks! Congratulations on your first contribution! :tada:

Repiteo avatar Nov 06 '24 00:11 Repiteo