emscripten + Saving editor state
pavanakumar opened this issue · 0 comments
pavanakumar commented
Imnodes saves the editor state to the ini file in lines 3232-3246 of file imnodes.cpp,
void SaveEditorStateToIniFile(const ImNodesEditorContext* const editor, const char* const file_name)
{
size_t data_size = 0u;
const char* data = SaveEditorStateToIniString(editor, &data_size);
FILE* file = ImFileOpen(file_name, "wt");
if (!file)
{
return;
}
fwrite(data, sizeof(char), data_size, file);
fclose(file);
}
Just by protecting this using the __EMSCRIPTEN__
macro helps,
void SaveEditorStateToIniFile(const ImNodesEditorContext* const editor, const char* const file_name)
{
#ifndef __EMSCRIPTEN__
size_t data_size = 0u;
const char* data = SaveEditorStateToIniString(editor, &data_size);
FILE* file = ImFileOpen(file_name, "wt");
if (!file)
{
return;
}
fwrite(data, sizeof(char), data_size, file);
fclose(file);
#endif
}
The browser does not allow access to the filesystem unless you are running this via Node. Just wanted to put this issue here if someone faced similar issue and wants a work around.