-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Search for .mem in same directory as Node script #4942
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,8 @@ if (memoryInitializer) { | |
| memoryInitializer = Module['locateFile'](memoryInitializer); | ||
| } else if (Module['memoryInitializerPrefixURL']) { | ||
| memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer; | ||
| } else if (ENVIRONMENT_IS_NODE) { | ||
| memoryInitializer = __dirname + '/' + memoryInitializer; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some questions do come to mind:
Last, I wonder if this would be better to read since
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively to make it more generic, perhaps we could have a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, it is.
Windows itself doesn't mind forward slashes and accepts either, so I wouldn't bother.
Yeah, as said above, I think for normal cases we want to load files relative to cwd, so that program would behave in the same way as when compiled natively.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I don't understand the idea for Perhaps we need something like
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kripken Overriding current working directory sounds irrelevant to this issue though? We want cwd to be still the same (at least where it exists for real, like in Node.js), it's only
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The idea to add this path name is a good solution. As commented earlier, I think it would be good to separate the location of initialization (platform specific) from the location of use (platform independent), so that we don't need to sprinkle // in preamble:
if (!Module['documentDirectory']) {
if (ENVIRONMENT_IS_NODE) Module['documentDirectory'] = __dirname + '/';
}
// in location(s) of use:
memoryInitializer = Module['documentDirectory'] + memoryInitializer;This way when we expand in the future to having multiple locations that need this fix, we can just slap the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh of course, I was thinking about having a generic function rather than copy-pasting in the worst case. Anyway, this idea sounds good to me, except the naming which might be confusing, especially on the browser side.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me too. |
||
| } | ||
| if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) { | ||
| var data = Module['readBinary'](memoryInitializer); | ||
|
|
||
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.
please add a comment here saying what this does
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.
Sorry, somehow missed this - added a comment.