-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Support drag&drop directories for GLFW #26081
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
Conversation
Change in GLFW.onDrop, when filesystem is enabled to support dropping directories
|
Hello! Please help me add new test for folder drop, I could only found https://github.com/emscripten-core/emscripten/blob/main/test/interactive/test_glfw_dropfile.c (which should work fine) but could not find how to run it locally |
sbc100
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't have automatic testing of this.
Is there perhaps a test in test_interactive.py that we could add? Or at least can you confirm you have tested this locally?
src/lib/libglfw.js
Outdated
| } | ||
| else { | ||
| // fallback for browsers that does not support `webkitGetAsEntry` | ||
| for (var i = 0; i < event.dataTransfer.files.length; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use for .. of here?
|
Thanks for comments, I have mostly updated code accordingly.
I will try to add something similar to |
|
Looks like closure compiler is complaining about: |
Oh, unfortunate typo. Fixed, thanks! |
To run that test locally you would do something like |
src/lib/libglfw.js
Outdated
| if (fpIndex > -1) entriesTree[parentpath].subpaths.splice(fpIndex, 1); | ||
| if (recursive) markDone(parentpath, true); | ||
| if (Object.keys(entriesTree).length == 0) finalize(); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove semicolon here and below.
Thanks! EDIT: full error: |
Does |
|
It moved forward with new error, thanks again: |
|
if you don't have |
|
I'm curious how the |
To run this I cloned clean And then The local test I have mentioned before was done within this PR in our APP
Running like this reveals that I miss Thanks! |
|
Now after installing npm and doing |
The looks like the correct way to go about it. However, emcc should complain if the I've uploaded this PR to make it more obvious: #26086 |
|
The idea with interactive tests is that you interact with the web page to confirm stuff is working. They don't get run very often so they tend to bitrot. Are you able to confirm the behaviour of the program while the test is running (before it gets reported as unresponsive). |
|
Seems that rebooting my PC fixed issues with the test somehow. |
| void on_file_drop(GLFWwindow *window, int count, const char **paths) { | ||
| for (int i = 0; i < count; ++i) { | ||
| printf("dropped file %s\n", paths[i]); | ||
| int flags = FTW_PHYS; // Do not follow symbolic links |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just inline FTW_PHYS in the call to nftw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
| */ | ||
|
|
||
| #include <stdio.h> | ||
| #include <ftw.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I've been using UNIX for over 30 years and I've never come across this API before! TIL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually it was suggest to me by google AI while searching how to traverse directory using C lang

Change in GLFW.onDrop when filesystem is enabled to support dropping directories