Files
turso/bindings/wasm/vfs.js
Pekka Enberg 933bf89bb9 wasm: VFS interface to use Node filesystem API
This adds a basic VFS interface to use Node filesystem API from Rust
code. Not a lot, but parses the SQLite database file header and
completes database open without errors.
2024-08-04 11:12:21 +03:00

24 lines
386 B
JavaScript

const fs = require('node:fs');
class VFS {
constructor() {
}
open(path) {
return fs.openSync(path, 'r');
}
close(fd) {
fs.closeSync(fd);
}
pread(fd, buffer, offset) {
return fs.readSync(fd, buffer, 0, buffer.length, offset);
}
pwrite(fd, buffer, offset) {
return fs.writeSync(fd, buffer, 0, buffer.length, offset);
}
}
module.exports = { VFS };