aboutsummaryrefslogtreecommitdiff
path: root/templates/web_shell/shell.html
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2018-11-26 17:16:26 +0100
committerRay <raysan5@gmail.com>2018-11-26 17:16:26 +0100
commit456483f10442ccdf896d798e57acf3906e8aaed5 (patch)
treea8ab306b66f1f5ac93aeee1a2215f62f7056199e /templates/web_shell/shell.html
parent969e48e3dd67ea26fd3e928914f0c1ffe7dfab23 (diff)
downloadraylib-456483f10442ccdf896d798e57acf3906e8aaed5.tar.gz
raylib-456483f10442ccdf896d798e57acf3906e8aaed5.zip
Allow file download from MEMFS
Support file download to disk from memory filesystem.
Diffstat (limited to 'templates/web_shell/shell.html')
-rw-r--r--templates/web_shell/shell.html18
1 files changed, 18 insertions, 0 deletions
diff --git a/templates/web_shell/shell.html b/templates/web_shell/shell.html
index 4dfefb8d..b5d1feed 100644
--- a/templates/web_shell/shell.html
+++ b/templates/web_shell/shell.html
@@ -159,6 +159,24 @@
<textarea id="output" rows="8"></textarea>
+ <script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
+ <script type='text/javascript'>
+ function SaveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
+ {
+ var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+ var data = FS.readFile(memoryFSname);
+ var blob;
+
+ if (isSafari) blob = new Blob([data.buffer], {type: "application/octet-stream"});
+ else blob = new Blob([data.buffer], {type: "application/octet-binary"});
+
+ // NOTE: SaveAs Dialog is a browser setting. For example, in Google Chrome,
+ // in Settings/Advanced/Downloads section you have a setting:
+ // 'Ask where to save each file before downloading' - which you can set true/false.
+ // If you enable this setting it would always ask you and bring the SaveAs Dialog
+ saveAs(blob, localFSname);
+ }
+ </script>
<script type='text/javascript'>
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');