2021-05-24 19:06:28 +00:00
|
|
|
export interface FileSystemGetFileOptions {
|
2021-12-18 13:55:31 +00:00
|
|
|
create?: boolean;
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface FileSystemCreateWritableOptions {
|
2021-12-18 13:55:31 +00:00
|
|
|
keepExistingData?: boolean;
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 20:36:32 +00:00
|
|
|
interface FileSystemRemoveOptions {
|
2021-12-18 13:55:31 +00:00
|
|
|
recursive?: boolean;
|
2021-05-24 20:36:32 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 19:06:28 +00:00
|
|
|
interface FileSystemFileHandle {
|
2021-12-18 13:55:31 +00:00
|
|
|
getFile(): Promise<File>;
|
2021-05-24 19:06:28 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
createWritable(options?: FileSystemCreateWritableOptions): Promise<FileSystemWritableFileStream>;
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum WriteCommandType {
|
2021-12-18 13:55:31 +00:00
|
|
|
write = 'write',
|
|
|
|
seek = 'seek',
|
|
|
|
truncate = 'truncate',
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface WriteParams {
|
2021-12-18 13:55:31 +00:00
|
|
|
type: WriteCommandType;
|
|
|
|
size?: number;
|
|
|
|
position?: number;
|
|
|
|
data: BufferSource | Blob | string;
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams;
|
2021-05-24 19:06:28 +00:00
|
|
|
|
|
|
|
interface FileSystemWritableFileStream extends WritableStream {
|
2021-12-18 13:55:31 +00:00
|
|
|
write(data: FileSystemWriteChunkType): Promise<undefined>;
|
2021-05-24 19:06:28 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
seek(position: number): Promise<undefined>;
|
2021-05-24 19:06:28 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
truncate(size: number): Promise<undefined>;
|
2021-05-24 19:06:28 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
close(): Promise<undefined>; // should be implemented in WritableStream
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export declare interface FileSystemDirectoryHandle {
|
2021-12-18 13:55:31 +00:00
|
|
|
getFileHandle(name: string, options?: FileSystemGetFileOptions): Promise<FileSystemFileHandle>;
|
2021-05-24 20:36:32 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
removeEntry(name: string, options?: FileSystemRemoveOptions): Promise<undefined>;
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare global {
|
2021-12-18 13:55:31 +00:00
|
|
|
interface Window {
|
|
|
|
showDirectoryPicker?(): Promise<FileSystemDirectoryHandle>;
|
|
|
|
}
|
2021-05-24 19:06:28 +00:00
|
|
|
}
|