1// GENERATED CONTENT - DO NOT EDIT
2// Content was automatically extracted by Reffy into webref
3// (https://github.com/w3c/webref)
4// Source: File System Access (https://wicg.github.io/file-system-access/)
5
6enum FileSystemPermissionMode {
7  "read",
8  "readwrite"
9};
10
11dictionary FileSystemPermissionDescriptor : PermissionDescriptor {
12  required FileSystemHandle handle;
13  FileSystemPermissionMode mode = "read";
14};
15
16dictionary FileSystemHandlePermissionDescriptor {
17  FileSystemPermissionMode mode = "read";
18};
19
20enum FileSystemHandleKind {
21  "file",
22  "directory",
23};
24
25[Exposed=(Window,Worker), SecureContext, Serializable]
26interface FileSystemHandle {
27  readonly attribute FileSystemHandleKind kind;
28  readonly attribute USVString name;
29
30  Promise<boolean> isSameEntry(FileSystemHandle other);
31
32  Promise<PermissionState> queryPermission(optional FileSystemHandlePermissionDescriptor descriptor = {});
33  Promise<PermissionState> requestPermission(optional FileSystemHandlePermissionDescriptor descriptor = {});
34};
35
36dictionary FileSystemCreateWritableOptions {
37  boolean keepExistingData = false;
38};
39
40[Exposed=(Window,Worker), SecureContext, Serializable]
41interface FileSystemFileHandle : FileSystemHandle {
42  Promise<File> getFile();
43  Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWritableOptions options = {});
44};
45
46dictionary FileSystemGetFileOptions {
47  boolean create = false;
48};
49
50dictionary FileSystemGetDirectoryOptions {
51  boolean create = false;
52};
53
54dictionary FileSystemRemoveOptions {
55  boolean recursive = false;
56};
57
58[Exposed=(Window,Worker), SecureContext, Serializable]
59interface FileSystemDirectoryHandle : FileSystemHandle {
60  async iterable<USVString, FileSystemHandle>;
61
62  Promise<FileSystemFileHandle> getFileHandle(USVString name, optional FileSystemGetFileOptions options = {});
63  Promise<FileSystemDirectoryHandle> getDirectoryHandle(USVString name, optional FileSystemGetDirectoryOptions options = {});
64
65  Promise<undefined> removeEntry(USVString name, optional FileSystemRemoveOptions options = {});
66
67  Promise<sequence<USVString>?> resolve(FileSystemHandle possibleDescendant);
68};
69
70enum WriteCommandType {
71  "write",
72  "seek",
73  "truncate",
74};
75
76dictionary WriteParams {
77  required WriteCommandType type;
78  unsigned long long? size;
79  unsigned long long? position;
80  (BufferSource or Blob or USVString)? data;
81};
82
83typedef (BufferSource or Blob or USVString or WriteParams) FileSystemWriteChunkType;
84
85[Exposed=(Window,Worker), SecureContext]
86interface FileSystemWritableFileStream : WritableStream {
87  Promise<undefined> write(FileSystemWriteChunkType data);
88  Promise<undefined> seek(unsigned long long position);
89  Promise<undefined> truncate(unsigned long long size);
90};
91
92enum WellKnownDirectory {
93  "desktop",
94  "documents",
95  "downloads",
96  "music",
97  "pictures",
98  "videos",
99};
100
101typedef (WellKnownDirectory or FileSystemHandle) StartInDirectory;
102
103dictionary FilePickerAcceptType {
104    USVString description;
105    record<USVString, (USVString or sequence<USVString>)> accept;
106};
107
108dictionary FilePickerOptions {
109    sequence<FilePickerAcceptType> types;
110    boolean excludeAcceptAllOption = false;
111    DOMString id;
112    StartInDirectory startIn;
113};
114
115dictionary OpenFilePickerOptions : FilePickerOptions {
116    boolean multiple = false;
117};
118
119dictionary SaveFilePickerOptions : FilePickerOptions {
120    USVString? suggestedName;
121};
122
123dictionary DirectoryPickerOptions {
124    DOMString id;
125    StartInDirectory startIn;
126};
127
128[SecureContext]
129partial interface Window {
130    Promise<sequence<FileSystemFileHandle>> showOpenFilePicker(optional OpenFilePickerOptions options = {});
131    Promise<FileSystemFileHandle> showSaveFilePicker(optional SaveFilePickerOptions options = {});
132    Promise<FileSystemDirectoryHandle> showDirectoryPicker(optional DirectoryPickerOptions options = {});
133};
134
135partial interface DataTransferItem {
136    Promise<FileSystemHandle?> getAsFileSystemHandle();
137};
138
139[SecureContext]
140partial interface StorageManager {
141  Promise<FileSystemDirectoryHandle> getDirectory();
142};
143