aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-fs.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-06-02 18:00:37 +0200
committerAgando <roduccomm@gmail.com>2026-06-02 18:00:37 +0200
commitaafb0fbde5289a45f9f818a00141f80b149be283 (patch)
treed4d8f588187719c99240fbaef1940c068402b892 /modules/core/module-fs.js
parent6d41e590a38c73ef60f1c04beaf8f5438f350f46 (diff)
auto: 2026-06-02_18:00 changes
Diffstat (limited to 'modules/core/module-fs.js')
-rw-r--r--modules/core/module-fs.js34
1 files changed, 30 insertions, 4 deletions
diff --git a/modules/core/module-fs.js b/modules/core/module-fs.js
index da2e740..b119343 100644
--- a/modules/core/module-fs.js
+++ b/modules/core/module-fs.js
@@ -279,18 +279,44 @@ class FileSystemModule {
this.commands['upload'] = () => { document.getElementById('file-upload-input').click(); };
this.commands['download'] = (args) => {
if(!args[0]) return this.terminal.print('Usage: download <filename>', 'warning');
- const content = this.terminal.fs.readFile(args[0]);
+ const fname = args[0];
+ const content = this.terminal.fs.readFile(fname);
if(content !== null && content !== undefined) {
+ const size = content.length;
+ const sizeStr = size > 1024 ? (size / 1024).toFixed(1) + ' KB' : size + ' B';
+ // Desktop: programmatic click (works on desktop Chrome/Firefox)
const blob = new Blob([content], {type: 'application/octet-stream'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
- a.href = url; a.download = args[0];
+ a.href = url; a.download = fname;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
setTimeout(() => { document.body.removeChild(a); URL.revokeObjectURL(url); }, 2000);
- this.terminal.print('Downloaded: ' + args[0], 'success');
- } else { this.terminal.print('download: ' + args[0] + ': No such file', 'error'); }
+ // Mobile fallback: build a DOM button with real user gesture
+ const line = document.createElement('div');
+ line.className = 'output-line';
+ const msg = document.createElement('span');
+ msg.textContent = '⬇ ' + fname + ' (' + sizeStr + ') ';
+ const btn = document.createElement('button');
+ btn.textContent = '⬇ Download';
+ btn.className = 'btn';
+ btn.style.cssText = 'background:var(--bg-tertiary);border:1px solid var(--border-color);color:var(--success-color);padding:4px 12px;border-radius:4px;cursor:pointer;font-size:0.85em;min-height:36px;';
+ btn.onclick = () => {
+ const b = new Blob([this.terminal.fs.readFile(fname)], {type: 'application/octet-stream'});
+ const u = URL.createObjectURL(b);
+ const el = document.createElement('a');
+ el.href = u; el.download = fname;
+ el.style.display = 'none';
+ document.body.appendChild(el);
+ el.click();
+ setTimeout(() => { document.body.removeChild(el); URL.revokeObjectURL(u); }, 2000);
+ };
+ line.appendChild(msg);
+ line.appendChild(btn);
+ this.terminal.outputContainer.appendChild(line);
+ this.terminal.scrollToBottom();
+ } else { this.terminal.print('download: ' + fname + ': No such file', 'error'); }
};
this.commands['vfs-export'] = () => {
const data = this.terminal.fs.root;