1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { Observable } from 'rxjs';
|
9 | import { Path, PathFragment } from '../path';
|
10 | export type FileBuffer = ArrayBuffer;
|
11 | export type FileBufferLike = ArrayBufferLike;
|
12 | export interface HostWatchOptions {
|
13 | readonly persistent?: boolean;
|
14 | readonly recursive?: boolean;
|
15 | }
|
16 | export declare enum HostWatchEventType {
|
17 | Changed = 0,
|
18 | Created = 1,
|
19 | Deleted = 2,
|
20 | Renamed = 3
|
21 | }
|
22 | export type Stats<T extends object = {}> = T & {
|
23 | isFile(): boolean;
|
24 | isDirectory(): boolean;
|
25 | readonly size: number;
|
26 | readonly atime: Date;
|
27 | readonly mtime: Date;
|
28 | readonly ctime: Date;
|
29 | readonly birthtime: Date;
|
30 | };
|
31 | export interface HostWatchEvent {
|
32 | readonly time: Date;
|
33 | readonly type: HostWatchEventType;
|
34 | readonly path: Path;
|
35 | }
|
36 | export interface HostCapabilities {
|
37 | synchronous: boolean;
|
38 | }
|
39 | export interface ReadonlyHost<StatsT extends object = {}> {
|
40 | readonly capabilities: HostCapabilities;
|
41 | read(path: Path): Observable<FileBuffer>;
|
42 | list(path: Path): Observable<PathFragment[]>;
|
43 | exists(path: Path): Observable<boolean>;
|
44 | isDirectory(path: Path): Observable<boolean>;
|
45 | isFile(path: Path): Observable<boolean>;
|
46 | stat(path: Path): Observable<Stats<StatsT> | null> | null;
|
47 | }
|
48 | export interface Host<StatsT extends object = {}> extends ReadonlyHost<StatsT> {
|
49 | write(path: Path, content: FileBufferLike): Observable<void>;
|
50 | delete(path: Path): Observable<void>;
|
51 | rename(from: Path, to: Path): Observable<void>;
|
52 | watch(path: Path, options?: HostWatchOptions): Observable<HostWatchEvent> | null;
|
53 | }
|