UNPKG

@zenfs/core

Version:

A filesystem, anywhere

75 lines (74 loc) 1.85 kB
// SPDX-License-Identifier: LGPL-3.0-or-later import { withErrno } from 'kerium'; /** * Implements the non-readonly methods to throw `EROFS` * @category Internals */ /* eslint-disable @typescript-eslint/require-await */ export function Readonly(FS) { class ReadonlyFS extends FS { constructor(...args) { super(...args); this.attributes.set('no_write'); } async rename() { throw withErrno('EROFS'); } renameSync() { throw withErrno('EROFS'); } async createFile() { throw withErrno('EROFS'); } createFileSync() { throw withErrno('EROFS'); } async unlink() { throw withErrno('EROFS'); } unlinkSync() { throw withErrno('EROFS'); } async rmdir() { throw withErrno('EROFS'); } rmdirSync() { throw withErrno('EROFS'); } async mkdir() { throw withErrno('EROFS'); } mkdirSync() { throw withErrno('EROFS'); } async link() { throw withErrno('EROFS'); } linkSync() { throw withErrno('EROFS'); } async touch() { throw withErrno('EROFS'); } touchSync() { throw withErrno('EROFS'); } async sync() { throw withErrno('EROFS'); } syncSync() { throw withErrno('EROFS'); } async write() { throw withErrno('EROFS'); } writeSync() { throw withErrno('EROFS'); } streamWrite() { throw withErrno('EROFS'); } } return ReadonlyFS; } /* eslint-enable @typescript-eslint/require-await */