diff --git a/index.bs b/index.bs index 823a94b..6a368a2 100644 --- a/index.bs +++ b/index.bs @@ -262,6 +262,8 @@ interface FileSystemHandle { readonly attribute FileSystemHandleKind kind; readonly attribute USVString name; + Promise remove(optional FileSystemRemoveOptions options = {}); + Promise isSameEntry(FileSystemHandle other); Promise queryPermission(optional FileSystemHandlePermissionDescriptor descriptor = {}); @@ -315,6 +317,64 @@ and return {{FileSystemHandleKind/"directory"}} otherwise. The name attribute must return the [=entry/name=] of the associated [=FileSystemHandle/entry=]. +### The {{FileSystemHandle/remove()}} method ### {#api-filesystemhandle-remove} + +
+ : await |handle| . {{FileSystemHandle/remove()|remove}}() + : await |handle| . {{FileSystemHandle/remove()|remove}}({ {{FileSystemRemoveOptions/recursive}}: false }) + :: Attempts to remove the entry represented by |handle| from the underlying file system. + + For files or directories with multiple hardlinks or symlinks, the entry which is deleted + is the entry corresponding to the path which was used to obtain the handle. + + Attempting to delete a file or directory that does not exist is considered success, + while attempting to delete a non-empty directory will result in a promise rejection. + + : await |handle| . {{FileSystemHandle/remove()|remove}}({ {{FileSystemRemoveOptions/recursive}}: true }) + :: Attempts to remove the entry represented by |handle| from the underlying file system. + + If the entry is a directory, its contents will also be deleted recursively. + + Attempting to delete a file or directory that does not exist is considered success. +
+ +
+The remove(|options|) method, +when invoked, must run these steps: + +1. Let |result| be [=a new promise=]. +1. Run the following steps [=in parallel=]: + 1. Let |entry| be [=this=]'s [=FileSystemHandle/entry=]. + 1. Let |permissionStatus| be the result of [=requesting file system permission=] + given [=this=] and {{"readwrite"}}. + If that throws an exception, [=reject=] |result| with that exception and abort. + 1. If |permissionStatus| is not {{PermissionState/"granted"}}, + [=/reject=] |result| with a {{NotAllowedError}} and abort. + + 1. Attempt to remove |entry| from the underlying file system. + 1. If |entry| is a [=directory entry=]: + 1. If |entry|'s path does not exist: + 1. [=/Reject=] |result| with a {{NotFoundError}} and abort. + 1. If |entry|'s path is not a directory: + 1. [=/Reject=] |result| with a {{TypeMismatchError}} and abort. + 1. If |entry| is not an empty directory and |options|.{{FileSystemRemoveOptions/recursive}} is `false`: + 1. [=/Reject=] |result| with an {{InvalidModificationError}} and abort. + 1. If |entry| is a [=file entry=]: + 1. If |entry|'s path does not exist: + 1. [=/Reject=] |result| with a {{NotFoundError}} and abort. + 1. If |entry|'s path is not a file: + 1. [=/Reject=] |result| with a {{TypeMismatchError}} and abort. + + Note: If {{FileSystemRemoveOptions/recursive}} is `true`, the removal can fail + non-atomically. Some files or directories might have been removed while other files + or directories still exist. + + 1. [=/Resolve=] |result| with `undefined`. + +1. Return |result|. + +
+ ### The {{FileSystemHandle/isSameEntry()}} method ### {#api-filesystemhandle-issameentry}
@@ -756,7 +816,6 @@ invoked, must run these steps: : await |directoryHandle| . {{FileSystemDirectoryHandle/removeEntry()|removeEntry}}(|name|, { {{FileSystemRemoveOptions/recursive}}: true }) :: Removes the entry named |name| in the directory represented by |directoryHandle|. If that entry is a directory, its contents will also be deleted recursively. - recursively. Attempting to delete a file or directory that does not exist is considered success.
@@ -782,14 +841,23 @@ these steps: 1. If |child|'s [=directory entry/children=] is not [=set/is empty|empty=] and |options|.{{FileSystemRemoveOptions/recursive}} is `false`: 1. [=/Reject=] |result| with an {{InvalidModificationError}} and abort. 1. [=set/Remove=] |child| from |entry|'s [=directory entry/children=]. - 1. If removing |child| in the underlying file system throws an exception, - [=/reject=] |result| with that exception and abort. + + 1. If |child| is a [=directory entry=]: + 1. If |child|'s path does not exist: + 1. [=/Reject=] |result| with a {{NotFoundError}} and abort. + 1. If |child|'s path is not a directory: + 1. [=/Reject=] |result| with a {{TypeMismatchError}} and abort. + + 1. If |child| is a [=file entry=]: + 1. If |child|'s path does not exist: + 1. [=/Reject=] |result| with a {{NotFoundError}} and abort. + 1. If |child|'s path is not a file: + 1. [=/Reject=] |result| with a {{TypeMismatchError}} and abort. Note: If {{FileSystemRemoveOptions/recursive}} is `true`, the removal can fail non-atomically. Some files or directories might have been removed while other files or directories still exist. - Issue(68): Better specify what possible exceptions this could throw. 1. [=/Resolve=] |result| with `undefined`. 1. [=/Reject=] |result| with a {{NotFoundError}}. 1. Return |result|.