Skip to content

Commit 633feed

Browse files
Remove copy and move methods. (#50)
These methods don't provide much value, since it is possible to get the same behavior using the existing read and write APIs.
1 parent e6850b7 commit 633feed

File tree

2 files changed

+6
-60
lines changed

2 files changed

+6
-60
lines changed

EXPLAINER.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,12 @@ const file_ref = await dir_ref.getFile('foo.js');
192192
// Get a subdirectory.
193193
const subdir = await dir_ref.getDirectory('bla', {createIfNotExists: true});
194194

195-
// And you can possibly do stuff like move and/or copy files around.
196-
await file_ref.copyTo(dir_ref, 'new_name', {overwrite: true});
195+
// No special API to create copies, but still possible to do so by using
196+
// available read and write APIs.
197+
const new_file = await dir_ref.getFile('new_name', {create: true});
198+
const new_file_writer = await new_file.createWriter();
199+
await new_file_writer.truncate(0);
200+
await new_file_writer.write(0, await file_ref.getFile());
197201
```
198202

199203
You can also check if two references reference the same file or directory (or at

index.bs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ interface FileSystemHandle {
7474
readonly attribute boolean isDirectory;
7575
readonly attribute USVString name;
7676

77-
Promise<FileSystemHandle> moveTo(USVString name);
78-
Promise<FileSystemHandle> moveTo(
79-
FileSystemDirectoryHandle parent, optional USVString name);
80-
Promise<FileSystemHandle> copyTo(
81-
FileSystemDirectoryHandle parent, optional USVString name);
8277
Promise<void> remove();
8378

8479
Promise<PermissionState> queryPermission(optional FileSystemHandlePermissionDescriptor descriptor);
@@ -110,59 +105,6 @@ associated [=FileSystemHandle/entry=] is a [=directory entry=], and false otherw
110105
The <dfn attribute for=FileSystemHandle>name</dfn> attribute must return the [=entry/name=] of the
111106
associated [=FileSystemHandle/entry=].
112107

113-
### The {{FileSystemHandle/moveTo()}} method ### {#api-filesystemhandle-moveto}
114-
115-
<div class="note domintro">
116-
: |newHandle| = await |handle| . {{FileSystemHandle/moveTo()|moveTo}}(|newName|)
117-
:: Renames the entry represented by |handle| to |newName|.
118-
119-
: |newHandle| = await |handle| . {{FileSystemHandle/moveTo()|moveTo}}(|otherDir|)
120-
:: Moves the entry represented by |handle| to |otherDir|, while keeping its existing name.
121-
122-
: |newHandle| = await |handle| . {{FileSystemHandle/moveTo()|moveTo}}(|otherDir|, |newName|)
123-
:: Moves the entry represented by |handle| to |otherDir|, while renaming it to |newName|.
124-
125-
In all of these cases, |handle| will no longer represent a valid entry, and thus any further
126-
operations on it will fail.
127-
128-
Attempting to move an entry to the directory it already exists in, without renaming it is
129-
an error. In all other cases if the target entry already exists, it is overwritten.
130-
</div>
131-
132-
<div algorithm>
133-
The <dfn method for=FileSystemHandle>moveTo(|parent|, |name|)</dfn> method, when invoked, must run
134-
these steps:
135-
136-
1. TODO
137-
138-
</div>
139-
140-
### The {{FileSystemHandle/copyTo()}} method ### {#api-filesystemhandle-copyto}
141-
142-
<div class="note domintro">
143-
: |newHandle| = await |handle| . {{FileSystemHandle/copyTo()|copyTo}}(|otherDir|)
144-
:: Creates a copy of the entry represented by |handle| in |otherDir|, while keeping its existing
145-
name.
146-
147-
: |newHandle| = await |handle| . {{FileSystemHandle/copyTo()|copyTo}}(|otherDir|, |newName|)
148-
:: Creates a copy of the entry represented by |handle| in |otherDir|, using |newName| for the
149-
name of the new entry.
150-
151-
In all of these cases, |handle| will no longer represent a valid entry, and thus any further
152-
operations on it will fail.
153-
154-
Attempting to copy an entry on top of itself will fail. In all other cases if the target entry
155-
already exists, it is overwritten.
156-
</div>
157-
158-
<div algorithm>
159-
The <dfn method for=FileSystemHandle>copyTo(|parent|, |name|)</dfn> method, when invoked, must run
160-
these steps:
161-
162-
1. TODO
163-
164-
</div>
165-
166108
### The {{FileSystemHandle/remove()}} method ### {#api-filesystemhandle-remove}
167109

168110
<div class="note domintro">

0 commit comments

Comments
 (0)