forked from mdn/content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
372 lines (289 loc) · 13.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
---
title: FileSystemEntrySync
slug: Web/API/FileSystemEntrySync
tags:
- API
- EntrySync
- File API
- File System API
- File and Directory Entries API
- FileSystemEntrySync
- Interface
- Non-standard
- Offline
- Reference
- filesystem
browser-compat: api.FileSystemEntrySync
---
<div>{{APIRef("File System API")}}{{Non-standard_header()}}</div>
<p>The <code>FileSystemEntrySync</code> interface of the File and Directory Entries API represents an entry in a file system; it can be either a {{domxref("FileEntrySync")}} or {{domxref("FileSystemDirectoryEntry")}}.</p>
<p>This interface includes methods for working with files—including copying, moving, removing, and reading files—as well as information about the file it points to—including the file name and its path from the root to the entry.</p>
<div class="warning">
<p><strong>Warning:</strong> This API was never accepted and never became standardized. Various browsers implement pieces of the <a href="/en-US/docs/Web/API/File_and_Directory_Entries_API">File and Directory Entries API</a> (otherwise known as the File System API) but you should try to avoid using it.</p>
</div>
<h2 id="basic">Basic concepts</h2>
<p>The <code>FileSystemEntrySync</code> interface includes methods that you would expect for manipulating files and directories, but it also include a really handy method for getting a URL of the entry: <code><a href="#tourl">toURL()</a></code>. It also introduces a new URL scheme: <code>filesystem:</code>.</p>
<p>You can use the <code>filesystem:</code> scheme on Google Chrome to see all the files and folders that are stored in the origin of your app. Just use <code>filesystem:</code> scheme for the root directory of the origin of the app. For example, if your app is in <code><a href="http://ww.html5rocks.com">http://ww.html5rocks.com</a></code>, open <code>filesystem:<a href="http://www.html5rocks.com/temporary/">http://www.html5rocks.com/temporary/</a></code> in a tab. Chrome shows a read-only list of all the files and folders stored the origin of your app.</p>
<h2 id="Method_overview">Method overview</h2>
<table class="standard-table">
<tbody>
<tr>
<td><code>Metadata <a href="#getmetada">getMetadata</a> () raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</code></td>
</tr>
<tr>
<td><code>FileSystemEntrySync <a href="#moveto">moveTo</a> (in <a href="/en-US/docs/Web/API/DirectoryEntrySync">DirectoryEntrySync</a> <em>parent</em>, optional DOMString <em>newName</em>) raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</code></td>
</tr>
<tr>
<td><code>FileSystemEntrySync <a href="#copyto">copyTo</a>(in <a href="/en-US/docs/Web/API/DirectoryEntrySync">DirectoryEntrySync</a> <em>parent</em>, optional DOMString <em>newName</em>) raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</code></td>
</tr>
<tr>
<td><code>DOMString <a href="#tourl">toURL</a>();</code></td>
</tr>
<tr>
<td><code>void <a href="#remove">remove</a>() raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</code></td>
</tr>
<tr>
<td><code>DirectoryEntrySync <a href="#getparent">getParent</a>();</code></td>
</tr>
</tbody>
</table>
<h2 id="Attributes">Attributes</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Attribute</th>
<th scope="col">Type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>filesystem</code></td>
<td><code>readonly FileSystemSync</code></td>
<td>The file system where the entry resides.</td>
</tr>
<tr>
<td><code>fullpath</code></td>
<td><code>readonly DOMString</code></td>
<td>
<p>The full absolute path from the root to the entry.</p>
<p>An absolute path is a relative path from the root directory, prepended with a '<code>/</code>'.</p>
</td>
</tr>
<tr>
<td><code>isDirectory</code></td>
<td><code>readonly boolean</code></td>
<td>True if FileSystemEntrySync is a directory.</td>
</tr>
<tr>
<td><code>isFile</code></td>
<td><code>readonly boolean</code></td>
<td>True if the FileSystemEntrySync is a file.</td>
</tr>
<tr>
<td><code>name</code></td>
<td><code>readonly DOMString</code></td>
<td>The name of the entry, excluding the path leading to it.</td>
</tr>
</tbody>
</table>
<h2 id="Methods">Methods</h2>
<h3 id="getMetadata">getMetadata()</h3>
<p>Look up metadata about this entry. [ todo: specify what kind of metadata ]</p>
<pre>Metadata getMetada ()
raises <code>(<a href="/en-US/docs/Web/API/FileException">FileException</a>)</code>;</pre>
<h4 id="Parameter">Parameter</h4>
<p>None</p>
<h4 id="Returns">Returns</h4>
<p>A <code>Metadata</code> object.</p>
<h4 id="Exceptions">Exceptions</h4>
<p>This method can raise a <a href="/en-US/docs/Web/API/FileException">FileException</a> with the following codes:</p>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Exception</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><code>NOT_FOUND_ERR</code></td>
<td>The entry does not exist.</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>INVALID_STATE_ERR</code></td>
<td>The FileSystemSync is no longer valid for some reason besides being deleted.</td>
</tr>
</tbody>
</table>
<h3 id="moveTo">moveTo()</h3>
<p>Move an entry to a different location on the file system. Moving a file over an existing file replaces that existing file. Moving a directory over an existing empty directory replaces that directory. [todo: What if the directory is not empty? ]</p>
<p>[todo: Verify ] This is the same method for renaming files. You can keep it in the same location and then define the <code>newName</code> parameter.</p>
<p>You cannot do the following:</p>
<ul>
<li>Move a directory inside itself or to any child at any depth</li>
<li>Move an entry into its parent if a name different from its current one isn't provided</li>
<li>Move a file to a path occupied by a directory or move a directory to a path occupied by a file</li>
<li>Move any element to a path occupied by a directory that is not empty.</li>
</ul>
<pre>FileSystemEntrySync moveTo (
in DirectoryEntrySync <em>parent</em>, optional DOMString <em>newName</em>
) raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</pre>
<h4 id="Parameters">Parameters</h4>
<dl>
<dt>parent</dt>
<dd>The directory to which to move the entry.</dd>
<dt>newName</dt>
<dd>The new name of the entry. If you do not specify a name, the browser preserves the entry's current name.</dd>
</dl>
<h4 id="Returns_2">Returns</h4>
<p>A <code>FileSystemEntrySync</code> object.</p>
<h4 id="Exceptions_2">Exceptions</h4>
<p>This method can raise a <a href="/en-US/docs/Web/API/FileException">FileException</a> with the following codes:</p>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Exception</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><code>ENCODING_ERR</code></td>
<td>The name supplied is invalid, because at least one of the characters is reserved or illegal. Examples include a backslash (\), dot (.), and two dots (..). </td>
</tr>
<tr>
<td><code>NOT_FOUND_ERR</code></td>
<td>The target directory does not exist.</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>INVALID_MODIFICATION_ERR</code></td>
<td>
<p>You tried one of the following disallowed operations:</p>
<ul>
<li>Moving an entry into its parent without changing its name</li>
<li>Moving a parent directory into one of its child directories. [todo: verify ]</li>
</ul>
</td>
</tr>
<tr>
<td><code>NO_MODIFICATION_ALLOWED_ERR</code></td>
<td>One of the following is not writable: the source entry, its parent directory, and the target directory.</td>
</tr>
</tbody>
</table>
<h3 id="copyTo">copyTo()</h3>
<p>Copy an entry to a different location on the file system. You cannot copy an entry inside itself if it is a directory, nor can you copy it into its parent without providing a new name. Directory copies are always recursive—that is, all contents of the directory are copied. You cannot change this behavior. Files are duplicated.</p>
<pre>void copyTo (
in DirectoryEntrySync <em>parent</em>, optional DOMString <em>newName</em>
) raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</pre>
<h4 id="Parameters_2">Parameters</h4>
<dl>
<dt>parent</dt>
<dd>The directory where you want the entry to move to.</dd>
<dt>newName</dt>
<dd>The new name of the entry. If you do not specify a name, the browser preserves the FileSystemEntrySync's current name.</dd>
</dl>
<h4 id="Returns_3">Returns</h4>
<p>A <code>FileSystemEntrySync</code> object.</p>
<h4 id="Exceptions_3">Exceptions</h4>
<p>This method can raise a <a href="/en-US/docs/Web/API/FileException">FileException</a> with the following codes:</p>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Exception</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><code>ENCODING_ERR</code></td>
<td>The name supplied is invalid, because at least one of the characters is reserved or illegal. Examples include a backslash (\), dot (.), and two dots (..). </td>
</tr>
<tr>
<td><code>NOT_FOUND_ERR</code></td>
<td>The target directory does not exist.</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>INVALID_MODIFICATION_ERR</code></td>
<td>
<p>You tried one of the following disallowed operations:</p>
<ul>
<li>Moving an entry into its parent without changing its name</li>
<li>Moving a parent directory into one of its child directories. </li>
</ul>
</td>
</tr>
<tr>
<td><code>NO_MODIFICATION_ALLOWED_ERR</code></td>
<td>One of the following is not writable: the source entry, its parent directory, and the target directory.</td>
</tr>
<tr>
<td><code>QUOTA_EXCEEDED_ERR</code></td>
<td>The operation would cause the application to exceed its storage quota. You can ask for a larger persistent storage, which your user must explicitly grant. For more information, see the article on <a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Introduction">basic concepts</a>. </td>
</tr>
</tbody>
</table>
<h3 id="toURL">toURL()</h3>
<p>Returns a URL that can be used to identify this entry. It exposes a new URL scheme—<code>filesystem:</code>—that you can use to fill <code>src</code> or <code>href </code>attributes. For example, if you wanted to display an image and have its <a href="/en-US/docs/Web/API/FileSystemFileEntry">fileEntry</a>, calling <code>toURL()</code> gives you the image file's file system URL. You get something like: <code>filesystem:<a href="http://example.com/temporary/lolcat.png">http://example.com/temporary/lolcat.png</a>.</code></p>
<p>The file system URL does not expire. Because the method describes a location on disk, the URL is valid for as long as that location exists. You can delete the file and recreate it, and it's all good. </p>
<p>You can supply the <code>mimeType</code> to simulate the optional MIME type header associated with HTTP downloads.</p>
<pre>DOMString toURL ();</pre>
<h4 id="Parameter_2">Parameter</h4>
<p>None.</p>
<h4 id="Returns_4">Returns</h4>
<p>A <code>DOMString</code> object.</p>
<h4 id="Exceptions_4">Exceptions</h4>
<p>None</p>
<h3 id="remove">remove()</h3>
<p>Deletes a file or directory. You cannot delete an empty directory or the root directory of a file system. If you want to remove an empty directory, use <a href="/en-US/docs/Web/API/DirectoryEntrySync#removerecursively()" rel="internal"><code>removeRecursively()</code></a> instead.</p>
<pre>void remove (
) raises (<a href="/en-US/docs/Web/API/FileException">FileException</a>);</pre>
<h4 id="Parameter_3">Parameter</h4>
<p>None</p>
<h4 id="Returns_5">Returns</h4>
<p>None.</p>
<h4 id="Exceptions_5">Exceptions</h4>
<p>This method can raise a <a href="/en-US/docs/Web/API/FileException">FileException</a> with the following codes:</p>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Exception</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><code>NOT_FOUND_ERR</code></td>
<td>The target directory does not exist.</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>INVALID_MODIFICATION_ERR</code></td>
<td>
<p>You tried to remove a directory that is not empty. If you want to remove an empty directory, use <a href="/en-US/docs/Web/API/DirectoryEntrySync#removerecursively()"><code>removeRecursively()</code></a> instead.</p>
</td>
</tr>
<tr>
<td><code>NO_MODIFICATION_ALLOWED_ERR</code></td>
<td>One of the following is not writable: the source entry, its parent directory, and the target directory.</td>
</tr>
</tbody>
</table>
<h3 id="getParent">getParent()</h3>
<p>Look up the parent <a href="/en-US/docs/Web/API/DirectoryEntrySync"><code>DirectoryEntrySync</code></a> containing the entry. If this entry is the root of its file system, then the parent is itself.</p>
<pre>void getParent ();</pre>
<h4 id="Parameter_4">Parameter</h4>
<p>None</p>
<h4 id="Returns_6">Returns</h4>
<dl>
<dt><code><a href="/en-US/docs/Web/API/DirectoryEntrySync">DirectoryEntrySync</a></code></dt>
<dd>An object that represents a directory in the file system.</dd>
</dl>
<h4 id="Exceptions_6">Exceptions</h4>
<p>None.</p>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat}}</p>
<h2 id="See_also">See also</h2>
<p>Specification:{{ spec("http://dev.w3.org/2009/dap/file-system/pub/FileSystem/", "File API: Directories and System Specification", "WD") }}</p>
<p>Reference: <a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Introduction">File System API</a></p>
<p>Introduction: <a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Introduction">Basic Concepts About the File System API</a></p>