aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/localfilesystemsync/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/localfilesystemsync/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/localfilesystemsync/index.html')
-rw-r--r--files/zh-cn/web/api/localfilesystemsync/index.html227
1 files changed, 227 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/localfilesystemsync/index.html b/files/zh-cn/web/api/localfilesystemsync/index.html
new file mode 100644
index 0000000000..799d89ee80
--- /dev/null
+++ b/files/zh-cn/web/api/localfilesystemsync/index.html
@@ -0,0 +1,227 @@
+---
+title: LocalFileSystemSync
+slug: Web/API/LocalFileSystemSync
+translation_of: Web/API/LocalFileSystemSync
+---
+<div>{{APIRef("File System API")}}{{non-standard_header()}}</div>
+
+<p><a href="/en/DOM/File_API/File_System_API" title="en/DOM/File_API/File_System_APIB">文件系统 API</a> 的 <code>LocalFileSystemSync</code> 接口允许你访问沙盒中的文件系统。它的目的是和 <a href="/en/DOM/Worker" title="en/DOM/Worker">WebWorkers</a> 一起使用。方法由 <a href="/en/DOM/Worker" title="En/DOM/Worker">worker</a> 对象实现。</p>
+
+<h2 id="关于这个文档">关于这个文档</h2>
+
+<p>这个文档最后更新于 2012 年 3 月 2 日,并遵循 <a class="external" href="http://www.w3.org/TR/file-system-api/">W3C 规范(工作草案)</a>,起草于 2011 年 4 月 19 日。</p>
+
+<p>这个规范或多或少已经废弃,没有得到大量的关注。</p>
+
+<h2 id="基本概念">基本概念</h2>
+
+<p>通过在 WebWorker 中请求 <code>LocalFileSystemSync</code> 对象,你可以请求访问沙盒文件系统。<code>window</code> 对象的全局方法 <code>requestFileSystemSync()</code> 和 <code>resolveLocalFileSystemSyncURL()</code> 暴露在 Worker 的全局域中。调用 <code>window.requestFileSystemSync()</code> 来为你的 Web 应用创建新的存储器。</p>
+
+<p>更多概念请见 <a href="/en/DOM/File_API/File_System_API/LocalFileSystem#Basic_concepts" title="https://developer.mozilla.org/en/DOM/File_API/File_System_API/LocalFileSystem#Basic_concepts">异步 API 的对应文章</a>。</p>
+
+<h3 id="示例">示例</h3>
+
+<pre class="brush: js">//Taking care of the browser-specific prefix
+window.requestFileSystemSync = window.requestFileSystemSync || window.webkitRequestFileSystemSync;
+
+// The first parameter defines the type of storage: persistent or temporary
+// Next, set the size of space needed (in bytes)
+// initFs is the success callback
+// And the last one is the error callback
+// for denial of access and other errors.
+
+var fs = requestFileSystemSync(TEMPORARY, 1024*1024 /*1MB*/);</pre>
+
+<p>由于你使用了同步 API,你并不需要成功或者错误回调。</p>
+
+<h2 id="方法概览">方法概览</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>FileSystemSync <a href="#requestFileSystemSync" title="#requestFileSystemSync">requestFileSystemSync</a> (in unsigned short <em>type</em>, in long long <em>size</em>) raises <a href="/en/DOM/File_API/File_System_API/FileException" title="en/DOM/File_API/File_System_API/FileException">FileException</a>; </code></td>
+ </tr>
+ <tr>
+ <td><code>EntrySync <a href="#resolveLocalFileSystemSyncURL" title="resolveLocalFileSystemSyncURL">resolveLocalFileSystemSyncURL</a> (in DOMString <em>url</em>) raises <a href="/en/DOM/File_API/File_System_API/FileException" title="en/DOM/File_API/File_System_API/FileException">FileException</a>;</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="常量">常量</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">常量</th>
+ <th scope="col">值</th>
+ <th scope="col">描述</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a name="const_temporary"><code>TEMPORARY</code></a></td>
+ <td><code>0</code></td>
+ <td>
+ <p>暂时的存储器,可由浏览器自主移除。</p>
+ </td>
+ </tr>
+ <tr>
+ <td><a name="const_persistent"><code>PERSISTENT</code></a></td>
+ <td><code>1</code></td>
+ <td>存在于浏览器的存储器,除非用户或者应用移除它。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="方法">方法</h2>
+
+<h3 id="requestFileSystem" name="requestFileSystem">requestFileSystemSync()</h3>
+
+<p>请求一个文件系统,数据应该储存到这里。通过在 WebWorker 中使用这个全局方法(<code>window.requestFileSystemSync()</code>)请求 <code>LocalFileSystemSync</code> 对象,来访问沙盒文件系统。 [ RESEARCH ]</p>
+
+<pre><code>FileSystemSync</code> requestFileSystemSync(
+ in unsigned short type,
+ in unsigned long long size
+);</pre>
+
+<h5 id="参数">参数</h5>
+
+<dl>
+ <dt>type</dt>
+ <dd>文件系统的储存类型。值为 <code><a href="#const_temporary">TEMPORARY</a></code> 或 <code><a href="#const_persistent">PERSISTENT</a>。</code></dd>
+ <dt>size</dt>
+ <dd>存储器的空间—按字节—你需要将其用于你的应用。</dd>
+</dl>
+
+<h5 id="返回值">返回值</h5>
+
+<dl>
+ <dt><code><a href="/en/DOM/File_API/File_System_API/FileSystemSync" title="en/DOM/File_API/File_System_API/FileSystemSync">FileSystemSync</a></code></dt>
+ <dd>表示文件系统的对象。</dd>
+</dl>
+
+<h5 id="异常">异常</h5>
+
+<p>这个方法可能产生 <a href="/en/DOM/File_API/File_System_API/FileException" title="en/DOM/File_API/File_System_API/FileException">FileException</a> ,带有下面的错误代码:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">异常</th>
+ <th scope="col">描述</th>
+ </tr>
+ <tr>
+ <td><code>SECURITY_ERROR</code></td>
+ <td>应用没有权限来访问文件系统接口。例如,你不能执行 <code>file://</code> 。更多细节请见 <a href="/en/DOM/File_APIs/Filesystem/Basic_Concepts_About_the_Filesystem_API#You_cannot_run_your_app_from_file:.2F.2F" title="https://developer.mozilla.org/en/DOM/File_APIs/Filesystem/Basic_Concepts_About_the_Filesystem_API#You_cannot_run_your_app_from_file:.2F.2F">基本概念的文章</a>。</td>
+ </tr>
+ </thead>
+</table>
+
+<h3 id="resolveLocalFileSystemSyncURL()" name="resolveLocalFileSystemSyncURL()">resolveLocalFileSystemSyncURL()</h3>
+
+<p>允许用户来检索文件或者目录的 <code>Entry</code> ,由本地 URL 引用。</p>
+
+<pre>void resolveLocalFileSystemURL(
+ in DOMString url
+);</pre>
+
+<h5 id="参数_2">参数</h5>
+
+<dl>
+ <dt>url</dt>
+ <dd>文件系统中的本地文件的 URL。</dd>
+</dl>
+
+<h5 id="返回值_2">返回值</h5>
+
+<dl>
+ <dt><code><a href="/en/DOM/File_API/File_System_API/EntrySync" title="en/DOM/File_API/File_System_API/EntrySync">EntrySync</a></code></dt>
+ <dd>表示文件系统中条目的对象。</dd>
+</dl>
+
+<h5 id="异常_2">异常</h5>
+
+<p>这个方法可能产生 <a href="/en/DOM/File_API/File_System_API/FileException" title="en/DOM/File_API/File_System_API/FileException">FileException</a> ,带有下列错误代码:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">异常</th>
+ <th scope="col">描述</th>
+ </tr>
+ <tr>
+ <td><code>ENCODING_ERR</code></td>
+ <td>URL 语法错误。</td>
+ </tr>
+ <tr>
+ <td><code>NOT_FOUND_ERR</code></td>
+ <td>URL 结构正确,但是指向了不存在的资源。</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>SECURITY_ERR</code></td>
+ <td>应用没有权限来访问文件系统接口。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_Compatibility" name="Browser_Compatibility">浏览器兼容性</h2>
+
+<p>{{ CompatibilityTable() }}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>13{{ property_prefix("webkit") }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{ CompatNo() }}</td>
+ <td>0.16{{ property_prefix("webkit") }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="另见">另见</h2>
+
+<p>规范:{{ spec("http://dev.w3.org/2009/dap/file-system/pub/FileSystem/", "File API: Directories and System Specification", "WD") }}</p>
+
+<p>参考:<a href="/en/DOM/File_API/File_System_API" title="en/DOM/File_API/File_System_API">文件系统 API</a></p>
+
+<p>简介: <a href="/en/DOM/File_APIs/Filesystem/Basic_Concepts_About_the_Filesystem_API" title="en/DOM/File_APIs/Filesystem/Basic_Concepts_About_the_Filesystem_API">文件系统 API 的基本概念</a>。</p>