FileSystemFlags

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

FileSystemFlags dictionary defines a set of values which are used when specifying option flags when calling certain methods in the 文件和目录条目 API . Methods which accept an options parameter of this type may specify zero or more of these flags as fields in an object, like this:

dataDirectoryEntry.getDirectory("Workspace", { create: true }, function(entry) {
});
					

Here, we see that the create property is provided, with a value of true , indicating that the directory should be created if it's not already there.

Note that these option flags currently don't have any useful meaning when used in the scope of Web content, where security precautions prevent the creation of new files or the replacement of existing ones.

特性

create 可选
若此特性为 true , and the requested file or directory doesn't exist, the user agent should create it. The default is false . The parent directory must already exist.
exclusive 可选
true ,和 create option is also true , the file must not exist prior to issuing the call. Instead, it must be possible for it to be created newly at call time. The default is false .

Values and results

The table below describes the result of each possible combination of these flags depending on whether or not the target file or directory path already exists.

Option values File/directory condition 结果
create exclusive
false n/a [1] Path exists and matches the desired type (depending on whether the function called is getFile() or getDirectory() successCallback is called with a FileSystemFileEntry if getFile() was called or a FileSystemDirectoryEntry if getDirectory() was called.
false n/a [1] Path exists but doesn't match the desired type errorCallback is called with an appropriate error code (if the callback was provided).
true false Path exists The existing file or directory is removed and replaced with a new one, then the successCallback is called with a FileSystemFileEntry FileSystemDirectoryEntry , as appropriate.
true false Path doesn't exist The file or directory is created, then a FileSystemFileEntry FileSystemDirectoryEntry 会被传递给 successCallback , as appropriate.
true true Path exists errorCallback is called with an appropriate error, such as FileError.PATH_EXISTS_ERR .
true true Path doesn't exist The file or directory is created, then a FileSystemFileEntry FileSystemDirectoryEntry 会被传递给 successCallback , as appropriate.

[1] When create is false , the value of exclusive is irrelevant and ignored.

规范

规范 状态 Comment
文件和目录条目 API
The definition of 'FileSystemFlags' in that specification.
草案 Initial specification.

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
FileSystemFlags
Chrome 13
Prefixed
13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ≤79
Prefixed
≤79
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox 50 IE No Opera No Safari No WebView Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 50 Opera Android No Safari iOS No Samsung Internet Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
create
Chrome 13
Prefixed
13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ≤79
Prefixed
≤79
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox 部分支持 50
部分支持 50
For security reasons, Firefox does not support creating files. This option has no effect.
IE No Opera No Safari No WebView Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 部分支持 50
部分支持 50
For security reasons, Firefox does not support creating files. This option has no effect.
Opera Android No Safari iOS No Samsung Internet Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
exclusive
Chrome 13
Prefixed
13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ≤79
Prefixed
≤79
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox 部分支持 50
部分支持 50
For security reasons, Firefox does not support creating files. This option has no effect.
IE No Opera No Safari No WebView Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 部分支持 50
部分支持 50
For security reasons, Firefox does not support creating files. This option has no effect.
Opera Android No Safari iOS No Samsung Internet Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit

图例

完整支持
完整支持
部分支持
部分支持
不支持
不支持
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
见实现注意事项。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅