非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
在
文件系统 API
,
FileException
object represents error conditions that you might encounter while accessing the file system using the synchronous API. It extends the FileException interface described in
File Writer
and adds several new error codes.
Synchronous APIs do not have error callbacks, which makes it difficult to catch errors. The added complexity of using
WebWorkers
with this API makes debugging even more challenging. To simplify things a bit, wrap your worker code in a try/catch. When errors occur, forward them to the main app using
postMessage()
as in the following:
function onError(e) {
postMEssage('ERROR:' + e.toString());
}
try {
//Error is thrown if "log.txt" already exists.
var fileEntry = fs.root.getFile('log.txt', {create: true, exclusive:true}0;
} catch (e) {
onErrror(e);
}
The sample code was borrowed from HTML5Rocks
| 属性 | 类型 | 描述 |
|---|---|---|
code
|
unsigned short
|
The most appropriate error code for the condition. |
| 常量 | 值 | 描述 |
|---|---|---|
ENCODING_ERR
|
5 | The URL is malformed. Make sure that the URL is complete and valid. |
INVALID_MODIFICATION_ERR
|
9 | The modification requested is not allowed. Examples of invalid modifications include moving a directory into its own child or moving a file into its parent directory without changing its name. |
INVALID_STATE_ERR
|
7 | The operation cannot be performed on the current state of the interface object. For example, the state that was cached in an interface object has changed since it was last read from disk. |
NO_MODIFICATION_ALLOWED_ERR
|
6 | The state of the underlying file system prevents any writing to a file or a directory. |
NOT_FOUND_ERR
|
1 | A required file or directory could not be found at the time an operation was processed. For example, a file did not exist but was being opened. |
NOT_READABLE_ERR
|
4 | The file or directory cannot be read, typically due to permission problems that occur after a reference to a file has been acquired (for example, the file or directory is concurrently locked by another application). |
PATH_EXISTS_ERR
|
12 | The file or directory with the same path already exists. |
QUOTA_EXCEEDED_ERR
|
10 | Either there's not enough remaining storage space or the storage quota was reached and the user declined to give more space to the database. |
SECURITY_ERR
|
2 |
Access to the files were denied for one of the following reasons:
|
TYPE_MISMATCH_ERR
|
11 | The user has attempted to look up a file or directory, but the Entry found is of the wrong type. For example, the app is accessing a DirectoryEntry when the user is requesting a FileEntry. |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileException
弃用
非标
|
Chrome
13 — 29
Prefixed
|
Edge No | Firefox No | IE No | Opera No | Safari No | WebView Android No |
Chrome Android
18 — 29
Prefixed
|
Firefox Android No | Opera Android No | Safari iOS No |
Samsung Internet Android
1.0 — 3.0
Prefixed
|
不支持
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
要求使用供应商前缀或不同名称。
规范: File API: Directories and System Specification WD
参考: 文件系统 API
介绍: Basic Concepts About the File System API
FileException
FileError
FileHandle
FileRequest
FileSystem
FileSystemDirectoryEntry
FileSystemDirectoryEntrySync
FileSystemDirectoryReader
FileSystemDirectoryReaderSync
FileSystemEntry
FileSystemEntrySync
FileSystemFileEntry
FileSystemFileEntrySync
FileSystemFlags
FileSystemSync
HTMLInputElement
LocalFileSystem
LocalFileSystemSync
LockedFile
元数据
Window.requestFileSystem()
Window.resolveLocalFileSystemURL()
WorkerGlobalScope.requestFileSystemSync()