Hacker News new | ask | show | jobs
by r1chardnl 658 days ago
Just a matter of time before Chrome pushes another JS API like File System API and you can actually defrag your drive from the browser.
3 comments

If you know the right identifiers, you should be able to use WebUSB to access a flash drive/external hard drive. Combined with C-to-WASM compilers and Linux driver code, I'm sure you can defragment from the browser alone.

Or you can hook this mechanism into one of the WASM x64 emulators and attach the drive directly to a copy of MS-DOS or Windows 98 running in the browser.

Why do APIs like this even exist? There's no legitimate reason for an HTML webpage to need this, it's just creating more attack surface for bad actors.
The File System API is a JavaScript API, not an HTML one, so it helps to think about it from that light (programs, not documents). The API allows tools such as photo editors, file converters, code editors, and the like to be given access to a set of files they can work on directly rather than needing to import and export from the browser on every change. If the attack surface is too much for a use case it can be globally denied by default in every major browser so you won't even get prompted.
JavaScript is just a feature accessory for HTML. There's no meaningful difference.
For whatever your preference in slicing that up is you can carry the "programs, not documents" reasons along.
Right, but programs are programs. Browsers are for webpages. If we want a program we run an .exe
The page needs permission. That permission step is similar to the act of downloading a native app. Except for the fact that the broswer gives even less access to your system than a native app so it's safer than a native app. (at least on desktop) That file system API is super useful for cloud based IDEs as just one example
Microsoft has an elaborate VS Code demo app that uses this API. Click "Open Folder" to see the API in action): https://vscode.dev
They say "like" this one because it only provides file level interaction, not disk level interaction.
Should already work today with your cloud storage I think