这篇翻译不完整。请帮忙从英语翻译这篇文章

非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

文件和目录条目API模拟一个web应用可以导航和访问的本地文件系统. 你在虚拟的沙箱文件系统中可以开发一个读, 写, 创建文件或者目录的应用.

Because this is a non-standard API, whose specification is not currently on a standards track, it's important to keep in mind that not all browsers implement it, and those that do may implement only small portions of it. Check the Browser compatibility section for details.

Two very similar APIs exist depending on whether you desire asynchronous or synchronous behavior. The synchronous API is indended to be used inside a Worker and will return the values you desire. The asynchronous API will not block and functions and the API will not return values; instead, you will need to supply a callback function to handle the response whenever it arrives.

The Firefox implementation of the File and Directory Entries API is very limited; there is no support for creating files. Only for accessing files which are selected by the user in a file <input> element (see HTMLInputElement as well) or when a file or directory is provided to the Web site or app using drag and drop. Firefox also does not implement the synchronous API. Check the browser compatibility for any part of the API you use carefully, and see File and Directory Entries API support in Firefox for more details.

Getting access to a file system

There are two ways to get access to file systems defined in the current specification draft:

Asynchronous API

The asynchronous API should be used for most operations, to prevent file system accesses from blocking the entire browser if used on the main thread. It includes the following interfaces:

FileSystem
Represents a file system.
FileSystemEntry
The basic interface representing a single entry in a file system. This is implemented by other interfaces which represent files or directories.
FileSystemFileEntry
Represents a single file in a file system.
FileSystemDirectoryEntry
Represents a single directory in a file system.
FileSystemDirectoryReader
Created by calling FileSystemDirectoryEntry.createReader(), this interface provides the functionality which lets you read the contents of a directory.
FileSystemFlags
Defines a set of values which are used when specifying option flags when calling certain methods in the File and Directory Entries API.
FileError
Represents an error which is generated by asynchronous file system calls.

There are also two global functions (which are not part of the specification at this time and are implemented only by Google Chrome). They're available on the Window object and implemented in LocalFileSystem: requestFileSystem() and resolveLocalFileSystemURL().

Synchronous API

The synchronous API is should only be used in Workers; these calls block until they're finished executing, and simply return the results instead of using callbacks. Using them on the main thread will block the browser, which is naughty. The interfaces below otherwise mirror the ones from the asynchronous API.

FileSystemSync
Represents a file system.
FileSystemEntrySync
The basic interface representing a single entry in a file system. This is implemented by other interfaces which represent files or directories. EntrySync
FileSystemFileEntrySync
Represents a single file in a file system.
FileSystemDirectoryEntrySync
Represents a single directory in a file system.
FileSystemDirectoryReaderSync
Created by calling FileSystemDirectoryEntrySync.createReader(), this interface provides the functionality which lets you read the contents of a directory.
FileException
Represents an error which is generated by synchronous file system calls.

There are also two global functions (which are not part of the specification at this time and are implemented only by Google Chrome). They're available on the Worker object and implemented in LocalFileSystemSync: requestFileSystemSync() and resolveLocalFileSystemSyncURL().

Other Interfaces

LocalFileSystem
Gives you access to a sandboxed file system.
LocalFileSystemSync
 
LockedFile
Provides tools to deal with a given file with all the necessary locks.
Metadata

Specifications

Specification Status Comment
File and Directory Entries API Draft Draft of proposed API

This API has no official W3C or WHATWG specification.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Asynchronous API 13 webkit 50 (50)[1] 未实现 未实现 未实现
Synchronous API 13 webkit 未实现 未实现 未实现 未实现
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Asynchronous API 未实现 (Yes) webkit 50.0 (50)[1] 未实现 未实现 未实现
Synchronous API 未实现 (Yes) webkit 未实现 未实现 未实现 未实现

[1] Firefox 50 introduces partial support for the File and Directory Entries API. Be sure to check the compatibility tables for individual interfaces and methods before using them, to ensure that they're supported, before you use them. The API can be disabled by setting the value of the preference dom.webkitBlink.filesystem.enabled to false.

See also

文档标签和贡献者

 此页面的贡献者: Clouds_W
 最后编辑者: Clouds_W,