@pgxsinkit/pgwasm
Version:
51 lines (47 loc) • 1.14 kB
JavaScript
// @bun
// packages/pgwasm/src/fs/base-filesystem.ts
var ERRNO_CODES2 = {
EBADF: 8,
EBADFD: 127,
EEXIST: 20,
EINVAL: 28,
EIO: 29,
EISDIR: 31,
ENODEV: 43,
ENOENT: 44,
ENOTDIR: 54,
ENOTEMPTY: 55
};
var MAX_SYSCALL_ERRORS = 50;
var DEFAULT_DESCRIPTION = Object.freeze({ name: "custom" });
class BaseFilesystem2 {
debug;
#recentSyscallErrors = [];
constructor({ debug = false } = {}) {
this.debug = debug;
}
get description() {
return DEFAULT_DESCRIPTION;
}
get recentSyscallErrors() {
return this.#recentSyscallErrors;
}
recordSyscallError(op, path, errno, message) {
const buffer = this.#recentSyscallErrors;
buffer.push({ op, path, errno, message, timeMs: Date.now() });
if (buffer.length > MAX_SYSCALL_ERRORS) {
buffer.shift();
}
if (this.debug) {
console.warn("[pgwasm-fs] syscall error", op, path, errno, message);
}
}
async syncToFs(_relaxed) {}
async initialSyncFs() {}
async closeFs() {}
async cleanupFailedInit() {
await this.closeFs();
}
}
export { ERRNO_CODES2, BaseFilesystem2 };
//# debugId=A14DDD1F35E244A664756E2164756E21