-
Notifications
You must be signed in to change notification settings - Fork 6
/
empty.ts
28 lines (27 loc) · 1.01 KB
/
empty.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { FileSystemDriver, FileSystemNode } from './index';
export class EmptyFS implements FileSystemDriver {
async resolveUri(path: string[]): Promise<string> {
throw new Error(path.length ? 'ENOTFOUND' : 'EISDIR');
}
async access(path: string[]): Promise<boolean> {
return !path.length;
}
async readDir(path: string[]): Promise<ReadableStream<FileSystemNode>> {
if (path.length)
throw new Error('ENOTFOUND');
return new ReadableStream({
start(c) {
c.close();
}
});
}
async readFile(path: string[], offset?: number, length?: number): Promise<ReadableStream<Uint8Array>> {
throw new Error(path.length ? 'ENOTFOUND' : 'EISDIR');
}
async writeFile(path: string[], offset: 'before' | 'after' | 'override', create: boolean): Promise<WritableStream<Uint8Array>> {
throw new Error(path.length ? 'EACCESS' : 'EISDIR');
}
async deleteNode(path: string[], recursive: boolean): Promise<void> {
throw new Error(path.length ? 'ENOTFOUND' : 'EBUSY');
}
}