Skip to content

Commit

Permalink
Update interfaces/native-file-system.idl and test
Browse files Browse the repository at this point in the history
Closes #22162
  • Loading branch information
stephenmcgruer committed Jun 11, 2020
1 parent 77211c4 commit 6a1c213
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
46 changes: 28 additions & 18 deletions interfaces/native-file-system.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ interface FileSystemHandle {
readonly attribute boolean isDirectory;
readonly attribute USVString name;

Promise<boolean> isSameEntry(FileSystemHandle other);

Promise<PermissionState> queryPermission(optional FileSystemHandlePermissionDescriptor descriptor = {});
Promise<PermissionState> requestPermission(optional FileSystemHandlePermissionDescriptor descriptor = {});
};

dictionary FileSystemCreateWriterOptions {
dictionary FileSystemCreateWritableOptions {
boolean keepExistingData = false;
};

[Exposed=(Window,Worker), SecureContext, Serializable]
interface FileSystemFileHandle : FileSystemHandle {
Promise<File> getFile();
Promise<FileSystemWriter> createWriter(optional FileSystemCreateWriterOptions options = {});
Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWritableOptions options = {});
};

dictionary FileSystemGetFileOptions {
Expand All @@ -41,20 +43,36 @@ dictionary FileSystemRemoveOptions {

[Exposed=(Window,Worker), SecureContext, Serializable]
interface FileSystemDirectoryHandle : FileSystemHandle {
async iterable<USVString, FileSystemHandle>;

Promise<FileSystemFileHandle> getFile(USVString name, optional FileSystemGetFileOptions options = {});
Promise<FileSystemDirectoryHandle> getDirectory(USVString name, optional FileSystemGetDirectoryOptions options = {});

// This really returns an async iterable, but that is not yet expressable in WebIDL.
object getEntries();

Promise<void> removeEntry(USVString name, optional FileSystemRemoveOptions options = {});

Promise<sequence<USVString>?> resolve(FileSystemHandle possibleDescendant);
};

enum WriteCommandType {
"write",
"seek",
"truncate",
};

dictionary WriteParams {
required WriteCommandType type;
unsigned long long? size;
unsigned long long? position;
(BufferSource or Blob or USVString)? data;
};

typedef (BufferSource or Blob or USVString or WriteParams) FileSystemWriteChunkType;

[Exposed=(Window,Worker), SecureContext]
interface FileSystemWriter {
Promise<void> write(unsigned long long position, (BufferSource or Blob or USVString) data);
interface FileSystemWritableFileStream : WritableStream {
Promise<void> write(FileSystemWriteChunkType data);
Promise<void> seek(unsigned long long position);
Promise<void> truncate(unsigned long long size);
Promise<void> close();
};

enum ChooseFileSystemEntriesType { "open-file", "save-file", "open-directory" };
Expand All @@ -78,15 +96,7 @@ partial interface Window {
chooseFileSystemEntries(optional ChooseFileSystemEntriesOptions options = {});
};

enum SystemDirectoryType {
"sandbox"
};

dictionary GetSystemDirectoryOptions {
required SystemDirectoryType type;
};

[SecureContext]
partial interface FileSystemDirectoryHandle {
static Promise<FileSystemDirectoryHandle> getSystemDirectory(GetSystemDirectoryOptions options);
partial interface mixin WindowOrWorkerGlobalScope {
Promise<FileSystemDirectoryHandle> getOriginPrivateDirectory();
};
2 changes: 1 addition & 1 deletion native-file-system/idlharness.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

idl_test(
['native-file-system'],
['html', 'dom'],
['streams', 'html', 'dom'],
idl_array => {
idl_array.add_objects({
// TODO: Add instances of FileSystemHandle, FileSystemFileHandle,
Expand Down

0 comments on commit 6a1c213

Please sign in to comment.