From 42c1f5601aa5b8796bbb361970299ad9aff0ad9d Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 25 Dec 2024 15:57:54 +0100 Subject: [PATCH] fix: Saving files in web version not working correctly --- lib/libimhex/source/helpers/fs.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index cbe5a0cf7..da43f2ee8 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -123,7 +123,13 @@ namespace hex::fs { // Call callback that will write the file 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(), { onload: () => { @@ -191,6 +197,7 @@ namespace hex::fs { else if (!validExtensions.empty()) path = "file." + validExtensions[0].spec; + std::fs::create_directory("/savedFiles"); callJs_saveFile(path.filename().string().c_str()); break; }