1
0
mirror of synced 2025-01-11 13:52:15 +01:00

fix: Saving files in web version not working correctly

This commit is contained in:
WerWolv 2024-12-25 15:57:54 +01:00
parent 9c1a673047
commit 42c1f5601a

View File

@ -123,7 +123,13 @@ namespace hex::fs {
// Call callback that will write the file // Call callback that will write the file
Module._fileBrowserCallback(stringToNewUTF8("/savedFiles/" + filename)); Module._fileBrowserCallback(stringToNewUTF8("/savedFiles/" + filename));
let data = FS.readFile("/savedFiles/" + filename); let data;
try {
data = FS.readFile("/savedFiles/" + filename);
} catch (e) {
console.log(e);
return;
}
const reader = Object.assign(new FileReader(), { const reader = Object.assign(new FileReader(), {
onload: () => { onload: () => {
@ -191,6 +197,7 @@ namespace hex::fs {
else if (!validExtensions.empty()) else if (!validExtensions.empty())
path = "file." + validExtensions[0].spec; path = "file." + validExtensions[0].spec;
std::fs::create_directory("/savedFiles");
callJs_saveFile(path.filename().string().c_str()); callJs_saveFile(path.filename().string().c_str());
break; break;
} }