import {ErrorWithContext} from '../../error/ErrorWithContext' import {Filesystem} from './Filesystem' import {Awaitable} from '../types' import {Writable} from 'stream' /** * Error thrown when attempting to perform an operation on a filesystem that doesn't support it. */ export class FilesystemOperationNotSupported extends ErrorWithContext { constructor(fs: Filesystem, operation: string, context: any = {}) { super(`The filesystem ${fs.constructor.name} does not support the ${operation} operation.`, context) } } /** * Abstract base class for filesystems that are read-only (e.g. HTTP/S). */ export abstract class ReadOnlyFilesystem extends Filesystem { putLocalFile(): Awaitable { throw new FilesystemOperationNotSupported(this, 'putLocalFile') } putStoreFileAsStream(): Awaitable { throw new FilesystemOperationNotSupported(this, 'putStoreFileAsStream') } touch(): Awaitable { throw new FilesystemOperationNotSupported(this, 'touch') } remove(): Awaitable { throw new FilesystemOperationNotSupported(this, 'remove') } mkdir(): Awaitable { throw new FilesystemOperationNotSupported(this, 'mkdir') } setMetadata(): Awaitable { throw new FilesystemOperationNotSupported(this, 'setMetadata') } }