-
Notifications
You must be signed in to change notification settings - Fork 173
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
support open files relative to script url parameter #17
support open files relative to script url parameter #17
Conversation
@embeddedt, @pmp-p - Could you review? |
fprintf(stderr," -> remote host[%s]\n", url); | ||
int fidx = EM_ASM_INT({return wasm_file_open(UTF8ToString($0)); }, url ); | ||
char fname[20]; | ||
snprintf(fname, sizeof(fname), "cache_%d", fidx); | ||
return fileno( fopen(fname,"r") ); | ||
} else { | ||
// file with no ':' - might be in the script folder | ||
int fidx = EM_ASM_INT({return wasm_file_open(UTF8ToString($0)); }, url ); |
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.
We now have this line duplicated in every branch of the if
statement. Can we consolidate these duplicated portions into a static function?
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.
Oh, you are right! I will refactor.
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.
the changes to file.c make local files a priority, it's a caching behaviour instead of filesystem implementation :
- caching behaviour would need more tests to be efficient.
- That makes it impossible for user to override firmware prebuilts files.
regarding imp.py : i'm against suppressing file open logs in browser console (stderr), chrome is already hiding emscripten stderr in the "android way" ( chromium does not) and i'm wary of that.
Ok, I will return it back. I just need to figure out why my mycropython is missing |
I was doing it to make sure that if the user opens the file and writes something to it, reading it will return him what he wrote. |
i think it's safer to always consider local filesystem as read only, and never assume one can write anywhere without an browser/user-auth at some point ( storage size is already restricted on some browsers because in fine you are writing to a ramdisk without knowing how much space is free).
that's a good idea but maybe it need some "this file is a product of "copy-on-write"" flag to set priority over the real up2date (remote) file. |
This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@stepansnigirev @pmp-p Was there any consensus on the points raised above? Does this PR need further refactoring? |
Yes, it needs further refactoring. I failed to compile emscripten port with warnings in |
Okay, no problem. Hopefully, someone takes an interest in completing this in the future! It seems that the main issue was fixing the issue with As a note to future readers: I did make some changes to stdio handling since this PR was last worked on so that may no longer be an issue. |
If
script=...
parameter is provided to the editor, the simulator will try to open resources with the same path.Example:
https://stepansnigirev.github.io/sim/?script_startup=https://gist.githubusercontent.com/stepansnigirev/d360caaca643a17989b1b41ceef417d1/raw/init_script.py&script=https://gist.githubusercontent.com/stepansnigirev/87032c693fd12eeb9dfd219535630691/raw/page.py
This page is loading the license content from the file stored in the same gist.
I also commented out print statements in
imp.py
as in my build I had an error thatsys.stderr
is not available.