mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-03 16:34:19 +01:00
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.
24 lines
386 B
JavaScript
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 }; |