FileSystemDirectoryEntry

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

FileSystemDirectoryEntry interface of the 文件和目录条目 API represents a directory in a file system. It provides methods which make it possible to access and manipulate the files in a directory, as well as to access the entries within the directory.

基本概念

You can create a new directory by calling getDirectory() . If you want to create subdirectories, create each child directory in sequence. If you try creating a directory using a full path that includes parent directories that do not exist yet, an error is returned. So create the hierarchy by recursively adding a new path after creating the parent directory.

范例

In the following code snippet, we create a directory called "Documents."

// Taking care of the browser-specific prefixes.
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.directoryEntry = window.directoryEntry || window.webkitDirectoryEntry;
...
function onFs(fs){
  fs.root.getDirectory('Documents', {create:true}, function(directoryEntry){
    //directoryEntry.isFile === false
    //directoryEntry.isDirectory === true
    //directoryEntry.name === 'Documents'
    //directoryEntry.fullPath === '/Documents'
    }, onError);
  }
// Opening a file system with temporary storage
window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, onFs, onError);
					

特性

This interface has no properties of its own, but inherits properties from its parent interface, FileSystemEntry .

方法

This interface inherits methods from its parent interface, FileSystemEntry .

createReader()
创建 FileSystemDirectoryReader object which can be used to read the entries in this directory.
getDirectory()
返回 FileSystemDirectoryEntry object representing a directory located at a given path, relative to the directory on which the method is called.
getFile()
返回 FileSystemFileEntry object representing a file located within the directory's hierarchy, given a path relative to the directory on which the method is called.

Obsolete methods

removeRecursively()
Deletes a directory and all of its contents, including the contents of subdirectories. This has been removed from the spec.

规范

规范 状态 Comment
文件和目录条目 API
The definition of 'FileSystemDirectoryEntry' in that 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
FileSystemDirectoryEntry
Chrome 8
Alternate Name
8
Alternate Name
Alternate Name Uses the non-standard name: DirectoryEntry
Edge 79
Prefixed
79
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox 50 IE No Opera Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari 11.1 WebView Android ≤37
Alternate Name
≤37
Alternate Name
Alternate Name Uses the non-standard name: DirectoryEntry
Chrome Android 18
Alternate Name
18
Alternate Name
Alternate Name Uses the non-standard name: DirectoryEntry
Firefox Android 50 Opera Android No Safari iOS 11.3 Samsung Internet Android Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
createReader
Chrome 13 Edge 79 Firefox 50 IE No Opera No Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 11.3 Samsung Internet Android Yes
getDirectory
Chrome 8 Edge 79 Firefox 50
50
In Firefox, the errorCallback 's input parameter is a DOMException rather than a FileError 对象。
IE No Opera No Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50
50
In Firefox, the errorCallback 's input parameter is a DOMException rather than a FileError 对象。
Opera Android No Safari iOS 11.3 Samsung Internet Android Yes
getFile
Chrome 8 Edge 79 Firefox 50
50
In Firefox, the errorCallback 's input parameter is a DOMException rather than a FileError 对象。
IE No Opera No Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50
50
In Firefox, the errorCallback 's input parameter is a DOMException rather than a FileError 对象。
Opera Android No Safari iOS 11.3 Samsung Internet Android Yes
removeRecursively
弃用 非标
Chrome 8 Edge 79 Firefox 50 — 52
不支持 50 — 52
While the removeRecursively() method existed, it immediately called the error callback with NS_ERROR_DOM_SECURITY_ERR .
IE No Opera No Safari No WebView Android ≤37 Chrome Android 18 Firefox Android 50 — 52
不支持 50 — 52
While the removeRecursively() method existed, it immediately called the error callback with NS_ERROR_DOM_SECURITY_ERR .
Opera Android No Safari iOS No Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。
使用非标名称。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅